Commit b7115bb4 by Sebastián Katzer

Update project

parent e27ee89f
......@@ -21,6 +21,7 @@
</receiver>
<activity android:exported="false" android:launchMode="singleInstance" android:name="de.appplant.cordova.plugin.notification.ClickActivity" android:theme="@android:style/Theme.NoDisplay" />
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
</manifest>
......@@ -308,6 +308,7 @@
<!-- IDs -->
<script type="text/javascript">
var callbackIds = function (ids) {
console.log(ids);
showToast(ids.length === 0 ? '- none -' : ids.join(' ,'));
};
......@@ -331,8 +332,13 @@
showToast(notifications.length === 0 ? '- none -' : notifications.join(' ,'));
};
var callbackSingleOpts = function (notification) {
console.log(notification);
showToast(notification.toString());
};
get = function () {
cordova.plugins.notification.local.get(1, callbackOpts);
cordova.plugins.notification.local.get(1, callbackSingleOpts);
};
getMultiple = function () {
......
......@@ -275,7 +275,8 @@ exports.get = function () {
scope = args[2];
if (!Array.isArray(ids)) {
ids = [ids];
this.exec('getSingle', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
......@@ -321,6 +322,11 @@ exports.getScheduled = function () {
ids = [ids];
}
if (!Array.isArray(ids)) {
this.exec('getSingleScheduled', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
this.exec('getScheduled', ids, callback, scope);
......@@ -364,6 +370,11 @@ exports.getTriggered = function () {
ids = [ids];
}
if (!Array.isArray(ids)) {
this.exec('getSingleTriggered', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
this.exec('getTriggered', ids, callback, scope);
......
......@@ -174,6 +174,15 @@ public class LocalNotification extends CordovaPlugin {
else if (action.equals("getTriggeredIds")) {
getTriggeredIds(command);
}
else if (action.equals("getSingle")) {
getSingle(args, command);
}
else if (action.equals("getSingleScheduled")) {
getSingleScheduled(args, command);
}
else if (action.equals("getSingleTriggered")) {
getSingleTriggered(args, command);
}
else if (action.equals("getAll")) {
getAll(args, command);
}
......@@ -369,23 +378,51 @@ public class LocalNotification extends CordovaPlugin {
}
/**
* Set of options from local notification.
* Options from local notification.
*
* @param ids
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getAll (JSONArray ids, CallbackContext command) {
List<JSONObject> options;
private void getSingle (JSONArray ids, CallbackContext command) {
getOptions(ids.optString(0), Notification.Type.ALL, command);
}
if (ids.length() == 0) {
options = getNotificationMgr().getOptions();
} else {
options = getNotificationMgr().getOptionsById(toList(ids));
}
/**
* Options from scheduled notification.
*
* @param ids
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getSingleScheduled (JSONArray ids, CallbackContext command) {
getOptions(ids.optString(0), Notification.Type.SCHEDULED, command);
}
command.success(new JSONArray(options));
/**
* Options from triggered notification.
*
* @param ids
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getSingleTriggered (JSONArray ids, CallbackContext command) {
getOptions(ids.optString(0), Notification.Type.TRIGGERED, command);
}
/**
* Set of options from local notification.
*
* @param ids
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getAll (JSONArray ids, CallbackContext command) {
getOptions(ids, Notification.Type.ALL, command);
}
/**
......@@ -397,16 +434,7 @@ public class LocalNotification extends CordovaPlugin {
* The callback context used when calling back into JavaScript.
*/
private void getScheduled (JSONArray ids, CallbackContext command) {
List<JSONObject> options;
if (ids.length() == 0) {
options = getNotificationMgr().getOptionsByType(Notification.Type.SCHEDULED);
} else {
options = getNotificationMgr().getOptionsBy(
Notification.Type.SCHEDULED, toList(ids));
}
command.success(new JSONArray(options));
getOptions(ids, Notification.Type.SCHEDULED, command);
}
/**
......@@ -418,13 +446,49 @@ public class LocalNotification extends CordovaPlugin {
* The callback context used when calling back into JavaScript.
*/
private void getTriggered (JSONArray ids, CallbackContext command) {
getOptions(ids, Notification.Type.TRIGGERED, command);
}
/**
* Options from local notification.
*
* @param id
* Set of local notification IDs
* @param type
* The local notification life cycle type
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getOptions (String id, Notification.Type type,
CallbackContext command) {
JSONArray ids = new JSONArray().put(id);
JSONObject options =
getNotificationMgr().getOptionsBy(type, toList(ids)).get(0);
command.success(options);
}
/**
* Set of options from local notifications.
*
* @param ids
* Set of local notification IDs
* @param type
* The local notification life cycle type
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getOptions (JSONArray ids, Notification.Type type,
CallbackContext command) {
List<JSONObject> options;
if (ids.length() == 0) {
options = getNotificationMgr().getOptionsByType(Notification.Type.TRIGGERED);
options = getNotificationMgr().getOptionsByType(type);
} else {
options = getNotificationMgr().getOptionsBy(
Notification.Type.TRIGGERED, toList(ids));
options = getNotificationMgr().getOptionsBy(type, toList(ids));
}
command.success(new JSONArray(options));
......
......@@ -48,7 +48,7 @@ import java.util.Set;
public class Manager {
// Context passed through constructor and used for notification builder.
private Context context;
private Context context;
/**
* Constructor
......@@ -56,9 +56,9 @@ public class Manager {
* @param context
* Application context
*/
private Manager(Context context){
this.context = context;
}
private Manager(Context context){
this.context = context;
}
/**
* Static method to retrieve class instance.
......@@ -256,6 +256,9 @@ public class Manager {
List<Notification> notifications = getAll();
ArrayList<Notification> list = new ArrayList<Notification>();
if (type == Notification.Type.ALL)
return notifications;
for (Notification notification : notifications) {
if (notification.getType() == type) {
list.add(notification);
......@@ -368,6 +371,9 @@ public class Manager {
public List<JSONObject> getOptionsBy(Notification.Type type,
List<Integer> ids) {
if (type == Notification.Type.ALL)
return getOptionsById(ids);
ArrayList<JSONObject> options = new ArrayList<JSONObject>();
List<Notification> notifications = getByIds(ids);
......
......@@ -46,7 +46,7 @@ public class Notification {
// Used to differ notifications by their life cycle state
public static enum Type {
SCHEDULED, TRIGGERED
ALL, SCHEDULED, TRIGGERED
}
// Default receiver to handle the trigger event
......
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
......@@ -23,6 +23,9 @@
</author>
<content src="index.html" />
<access origin="*" />
<feature name="Toast">
<param name="ios-package" value="Toast" />
</feature>
<feature name="Device">
<param name="ios-package" value="CDVDevice" />
</feature>
......@@ -30,7 +33,4 @@
<param name="ios-package" onload="true" value="APPLocalNotification" />
<param name="onload" value="true" />
</feature>
<feature name="Toast">
<param name="ios-package" value="Toast" />
</feature>
</widget>
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
{
"file": "plugins/nl.x-services.plugins.toast/www/Toast.js",
"id": "nl.x-services.plugins.toast.Toast",
"clobbers": [
"window.plugins.toast"
]
},
{
"file": "plugins/nl.x-services.plugins.toast/test/tests.js",
"id": "nl.x-services.plugins.toast.tests"
},
{
"file": "plugins/de.appplant.cordova.plugin.local-notification/www/local-notification.js",
"id": "de.appplant.cordova.plugin.local-notification.LocalNotification",
"clobbers": [
......@@ -25,17 +36,6 @@ module.exports = [
]
},
{
"file": "plugins/nl.x-services.plugins.toast/www/Toast.js",
"id": "nl.x-services.plugins.toast.Toast",
"clobbers": [
"window.plugins.toast"
]
},
{
"file": "plugins/nl.x-services.plugins.toast/test/tests.js",
"id": "nl.x-services.plugins.toast.tests"
},
{
"file": "plugins/org.apache.cordova.device/www/device.js",
"id": "org.apache.cordova.device.device",
"clobbers": [
......@@ -46,8 +46,8 @@ module.exports = [
module.exports.metadata =
// TOP OF METADATA
{
"de.appplant.cordova.plugin.local-notification": "0.8.2dev",
"nl.x-services.plugins.toast": "2.0.3",
"de.appplant.cordova.plugin.local-notification": "0.8.2dev",
"org.apache.cordova.device": "0.3.0"
}
// BOTTOM OF METADATA
......
......@@ -308,6 +308,7 @@
<!-- IDs -->
<script type="text/javascript">
var callbackIds = function (ids) {
console.log(ids);
showToast(ids.length === 0 ? '- none -' : ids.join(' ,'));
};
......@@ -331,8 +332,13 @@
showToast(notifications.length === 0 ? '- none -' : notifications.join(' ,'));
};
var callbackSingleOpts = function (notification) {
console.log(notification);
showToast(notification.toString());
};
get = function () {
cordova.plugins.notification.local.get(1, callbackOpts);
cordova.plugins.notification.local.get(1, callbackSingleOpts);
};
getMultiple = function () {
......
......@@ -275,7 +275,8 @@ exports.get = function () {
scope = args[2];
if (!Array.isArray(ids)) {
ids = [ids];
this.exec('getSingle', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
......@@ -321,6 +322,11 @@ exports.getScheduled = function () {
ids = [ids];
}
if (!Array.isArray(ids)) {
this.exec('getSingleScheduled', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
this.exec('getScheduled', ids, callback, scope);
......@@ -364,6 +370,11 @@ exports.getTriggered = function () {
ids = [ids];
}
if (!Array.isArray(ids)) {
this.exec('getSingleTriggered', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
this.exec('getTriggered', ids, callback, scope);
......
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputPath>build\windows80\$(Configuration)\$(Platform)\</OutputPath>
<IntermediateOutputPath>build\windows80\bld\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>efffab2f-bfc5-4eda-b545-45ef4995f55a</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0'">
<VisualStudioVersion>11.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" />
<PropertyGroup>
<TargetPlatformIdentifier>Windows</TargetPlatformIdentifier>
<TargetPlatformVersion>8.0</TargetPlatformVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<PackageCertificateKeyFile>CordovaApp_TemporaryKey.pfx</PackageCertificateKeyFile>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="package.windows80.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="images\*.png" Exclude="images\*.scale-240.*" />
<None Include="CordovaApp_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<SDKReference Include="Microsoft.WinJS.1.0, Version=1.0" />
</ItemGroup>
<Import Project="CordovaApp.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" />
<PropertyGroup>
<BuildFromCordovaTooling>false</BuildFromCordovaTooling>
<PreBuildEvent Condition="$(BuildFromCordovaTooling) != true">
cd /d $(MSBuildThisFileDirectory)
node -e "require('./cordova/lib/prepare.js').applyPlatformConfig()"
</PreBuildEvent>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
<Identity Name="e8de53c0-cf2d-11e4-8bb0-9369d008f7b1" Version="1.0.0.0" Publisher="CN=$username$" />
<Properties>
<DisplayName>NotificationExample</DisplayName>
<PublisherDisplayName>$username$</PublisherDisplayName>
<Logo>images\storelogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.2.1</OSMinVersion>
<OSMaxVersionTested>6.2.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="de.appplant.localnotification.example" StartPage="www/index.html">
<VisualElements DisplayName="NotificationExample"
Logo="images\Square150x150Logo.png"
SmallLogo="images\Square30x30Logo.png"
Description="CordovaApp"
ForegroundText="light"
BackgroundColor="#464646">
<DefaultTile ShowName="allLogos" WideLogo="images\Wide310x150Logo.png"/>
<SplashScreen Image="images\splashscreen.png" />
</VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ReferenceCachePath>C:\Users\sebastian\AppData\Local\Temp\yxmokjnx_CordovaApp.Phone_refcache</ReferenceCachePath>
<AutoRefresh>true</AutoRefresh>
</PropertyGroup>
<PropertyGroup />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ReferenceCachePath>C:\Users\sebastian\AppData\Local\Temp\anloqo42_CordovaApp.Windows_refcache</ReferenceCachePath>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
......@@ -16,81 +16,78 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputPath>build\windows80\$(Configuration)\$(Platform)\</OutputPath>
<IntermediateOutputPath>build\windows80\bld\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>efffab2f-bfc5-4eda-b545-45ef4995f55a</ProjectGuid>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0'">
<VisualStudioVersion>12.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" />
<PropertyGroup>
<TargetPlatformIdentifier>Windows</TargetPlatformIdentifier>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<PackageCertificateKeyFile>CordovaApp_TemporaryKey.pfx</PackageCertificateKeyFile>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="package.windows80.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="images\*.png" Exclude="images\*.scale-240.*" />
<None Include="CordovaApp_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<SDKReference Include="Microsoft.WinJS.2.0, Version=1.0" />
</ItemGroup>
<Import Project="CordovaApp.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" />
<PropertyGroup>
<BuildFromCordovaTooling>false</BuildFromCordovaTooling>
-->
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputPath>build\windows80\$(Configuration)\$(Platform)\</OutputPath>
<IntermediateOutputPath>build\windows80\bld\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>efffab2f-bfc5-4eda-b545-45ef4995f55a</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0'">
<VisualStudioVersion>11.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" />
<PropertyGroup>
<TargetPlatformIdentifier>Windows</TargetPlatformIdentifier>
<TargetPlatformVersion>8.0</TargetPlatformVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<PackageCertificateKeyFile>CordovaApp_TemporaryKey.pfx</PackageCertificateKeyFile>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="package.windows80.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="images\*.png" Exclude="images\*.scale-240.*" />
<None Include="CordovaApp_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<SDKReference Include="Microsoft.WinJS.1.0, Version=1.0" />
</ItemGroup>
<Import Project="CordovaApp.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" />
<PropertyGroup>
<BuildFromCordovaTooling>false</BuildFromCordovaTooling>
<PreBuildEvent Condition="$(BuildFromCordovaTooling) != true">
cd /d $(MSBuildThisFileDirectory)
node -e "require('./cordova/lib/prepare.js').applyPlatformConfig()"
</PreBuildEvent>
</PropertyGroup>
</PreBuildEvent>
</PropertyGroup>
</Project>
\ No newline at end of file
......@@ -25,8 +25,8 @@
Weitere Informationen zu Paketmanifestdateien finden Sie unter http://go.microsoft.com/fwlink/?LinkID=241727
-->
<Identity Name="e8de53c0-cf2d-11e4-8bb0-9369d008f7b1" Version="1.0.0.0" Publisher="CN=$username$" ProcessorArchitecture="neutral" />
<mp:PhoneIdentity PhoneProductId="e8de53c0-cf2d-11e4-8bb0-9369d008f7b1" PhonePublisherId="db093ed5-53b1-45f7-af72-751e8f36ab80" />
<Identity Name="c05631e0-de03-11e4-96be-cfbf5b6cb232" Version="1.0.0.0" Publisher="CN=$username$" ProcessorArchitecture="neutral" />
<mp:PhoneIdentity PhoneProductId="c05631e0-de03-11e4-96be-cfbf5b6cb232" PhonePublisherId="db093ed5-53b1-45f7-af72-751e8f36ab80" />
<Properties>
<DisplayName>NotificationExample</DisplayName>
<PublisherDisplayName>$username$</PublisherDisplayName>
......
......@@ -6,7 +6,7 @@
<TargetPlatformIdentifier>WindowsPhoneApp</TargetPlatformIdentifier>
<SolutionConfiguration>Debug|AnyCPU</SolutionConfiguration>
<PackageArchitecture>neutral</PackageArchitecture>
<PackageIdentityName>e8de53c0-cf2d-11e4-8bb0-9369d008f7b1</PackageIdentityName>
<PackageIdentityName>c05631e0-de03-11e4-96be-cfbf5b6cb232</PackageIdentityName>
<IntermediateOutputPath>Y:\Documents\github\cordova-example-local-notifications\platforms\windows\build\phone\bld\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
......@@ -79,6 +79,12 @@
<AppxPackagedFile Include="Y:\Documents\github\cordova-example-local-notifications\platforms\windows\www\js\index.js">
<PackagePath>www\js\index.js</PackagePath>
</AppxPackagedFile>
<AppxPackagedFile Include="Y:\Documents\github\cordova-example-local-notifications\platforms\windows\www\plugins\de.appplant.cordova.plugin.email-composer\src\windows\EmailComposerProxy.js">
<PackagePath>www\plugins\de.appplant.cordova.plugin.email-composer\src\windows\EmailComposerProxy.js</PackagePath>
</AppxPackagedFile>
<AppxPackagedFile Include="Y:\Documents\github\cordova-example-local-notifications\platforms\windows\www\plugins\de.appplant.cordova.plugin.email-composer\www\email_composer.js">
<PackagePath>www\plugins\de.appplant.cordova.plugin.email-composer\www\email_composer.js</PackagePath>
</AppxPackagedFile>
<AppxPackagedFile Include="Y:\Documents\github\cordova-example-local-notifications\platforms\windows\www\plugins\de.appplant.cordova.plugin.local-notification\src\windows\LocalNotificationCore.js">
<PackagePath>www\plugins\de.appplant.cordova.plugin.local-notification\src\windows\LocalNotificationCore.js</PackagePath>
</AppxPackagedFile>
......
......@@ -19,6 +19,8 @@ www\css\index.css
www\img\logo.png
www\index.html
www\js\index.js
www\plugins\de.appplant.cordova.plugin.email-composer\src\windows\EmailComposerProxy.js
www\plugins\de.appplant.cordova.plugin.email-composer\www\email_composer.js
www\plugins\de.appplant.cordova.plugin.local-notification\src\windows\LocalNotificationCore.js
www\plugins\de.appplant.cordova.plugin.local-notification\src\windows\LocalNotificationProxy.js
www\plugins\de.appplant.cordova.plugin.local-notification\src\windows\LocalNotificationUtil.js
......
......@@ -19,6 +19,8 @@ www\css\index.css
www\img\logo.png
www\index.html
www\js\index.js
www\plugins\de.appplant.cordova.plugin.email-composer\src\windows\EmailComposerProxy.js
www\plugins\de.appplant.cordova.plugin.email-composer\www\email_composer.js
www\plugins\de.appplant.cordova.plugin.local-notification\src\windows\LocalNotificationCore.js
www\plugins\de.appplant.cordova.plugin.local-notification\src\windows\LocalNotificationProxy.js
www\plugins\de.appplant.cordova.plugin.local-notification\src\windows\LocalNotificationUtil.js
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
......@@ -16,36 +16,42 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="e8de53c0-cf2d-11e4-8bb0-9369d008f7b1" Version="1.0.0.0" Publisher="CN=$username$" />
<mp:PhoneIdentity PhoneProductId="e8de53c0-cf2d-11e4-8bb0-9369d008f7b1" PhonePublisherId="db093ed5-53b1-45f7-af72-751e8f36ab80" />
<Properties>
<DisplayName>NotificationExample</DisplayName>
<PublisherDisplayName>$username$</PublisherDisplayName>
<Logo>images\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="de.appplant.localnotification.example" StartPage="www/index.html">
<m3:VisualElements ToastCapable="true" DisplayName="NotificationExample" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png" Description="CordovaApp" ForegroundText="light" BackgroundColor="transparent">
<m3:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" Square71x71Logo="images\Square71x71Logo.png">
<m3:ShowNameOnTiles>
<m3:ShowOn Tile="square150x150Logo" />
<m3:ShowOn Tile="wide310x150Logo" />
</m3:ShowNameOnTiles>
</m3:DefaultTile>
<m3:SplashScreen Image="images\SplashScreenPhone.png" />
</m3:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClientServer" />
</Capabilities>
-->
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="c05631e0-de03-11e4-96be-cfbf5b6cb232" Version="1.0.0.0" Publisher="CN=$username$" />
<mp:PhoneIdentity PhoneProductId="c05631e0-de03-11e4-96be-cfbf5b6cb232" PhonePublisherId="db093ed5-53b1-45f7-af72-751e8f36ab80" />
<Properties>
<DisplayName>NotificationExample</DisplayName>
<PublisherDisplayName>$username$</PublisherDisplayName>
<Logo>images\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="de.appplant.localnotification.example" StartPage="www/index.html">
<m3:VisualElements ToastCapable="true" DisplayName="NotificationExample"
Square150x150Logo="images\Square150x150Logo.png"
Square44x44Logo="images\Square44x44Logo.png"
Description="CordovaApp"
ForegroundText="light"
BackgroundColor="transparent">
<m3:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png"
Square71x71Logo="images\Square71x71Logo.png">
<m3:ShowNameOnTiles>
<m3:ShowOn Tile="square150x150Logo" />
<m3:ShowOn Tile="wide310x150Logo" />
</m3:ShowNameOnTiles>
</m3:DefaultTile>
<m3:SplashScreen Image="images\SplashScreenPhone.png" />
</m3:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClientServer" />
</Capabilities>
</Package>
\ No newline at end of file
......@@ -18,7 +18,7 @@
under the License.
-->
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
<Identity Name="e8de53c0-cf2d-11e4-8bb0-9369d008f7b1" Version="1.0.0.0" Publisher="CN=$username$" />
<Identity Name="c05631e0-de03-11e4-96be-cfbf5b6cb232" Version="1.0.0.0" Publisher="CN=$username$" />
<Properties>
<DisplayName>NotificationExample</DisplayName>
<PublisherDisplayName>$username$</PublisherDisplayName>
......@@ -33,7 +33,7 @@
</Resources>
<Applications>
<Application Id="de.appplant.localnotification.example" StartPage="www/index.html">
<m2:VisualElements DisplayName="NotificationExample"
<m2:VisualElements ToastCapable="true" DisplayName="NotificationExample"
Description="CordovaApp"
ForegroundText="light"
BackgroundColor="#464646"
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
......@@ -16,35 +16,35 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
<Identity Name="e8de53c0-cf2d-11e4-8bb0-9369d008f7b1" Version="1.1.0.0" Publisher="CN=$username$" />
<Properties>
<DisplayName>NotificationExample</DisplayName>
<PublisherDisplayName>$username$</PublisherDisplayName>
<Logo>images\storelogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.0</OSMinVersion>
<OSMaxVersionTested>6.3.0</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="de.appplant.localnotification.example" StartPage="www/index.html">
<m2:VisualElements DisplayName="NotificationExample" Description="CordovaApp" BackgroundColor="#464646" ForegroundText="light" Square150x150Logo="images\Square150x150Logo.png" Square30x30Logo="images\Square30x30Logo.png">
<m2:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png">
<m2:ShowNameOnTiles>
<m2:ShowOn Tile="square150x150Logo" />
<m2:ShowOn Tile="wide310x150Logo" />
</m2:ShowNameOnTiles>
</m2:DefaultTile>
<m2:SplashScreen Image="images\splashscreen.png" />
</m2:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
-->
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
<Identity Name="c05631e0-de03-11e4-96be-cfbf5b6cb232" Version="1.0.0.0" Publisher="CN=$username$" />
<Properties>
<DisplayName>NotificationExample</DisplayName>
<PublisherDisplayName>$username$</PublisherDisplayName>
<Logo>images\storelogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.2.1</OSMinVersion>
<OSMaxVersionTested>6.2.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="de.appplant.localnotification.example" StartPage="www/index.html">
<VisualElements ToastCapable="true" DisplayName="NotificationExample"
Logo="images\Square150x150Logo.png"
SmallLogo="images\Square30x30Logo.png"
Description="CordovaApp"
ForegroundText="light"
BackgroundColor="#464646">
<DefaultTile ShowName="allLogos" WideLogo="images\Wide310x150Logo.png"/>
<SplashScreen Image="images\splashscreen.png" />
</VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>
\ No newline at end of file
......@@ -1298,7 +1298,7 @@ module.exports = {
scriptElem.src = "//Microsoft.WinJS.2.0/js/base.js";
} else {
// windows 8.0 + IE 10
scriptElem.src = "//Microsoft.WinJS.2.0/js/base.js";
scriptElem.src = "//Microsoft.WinJS.1.0/js/base.js";
}
scriptElem.addEventListener("load", onWinJSReady);
document.head.appendChild(scriptElem);
......
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
{
"file": "plugins/nl.x-services.plugins.toast/www/Toast.js",
"id": "nl.x-services.plugins.toast.Toast",
"clobbers": [
"window.plugins.toast"
]
},
{
"file": "plugins/nl.x-services.plugins.toast/test/tests.js",
"id": "nl.x-services.plugins.toast.tests"
},
{
"file": "plugins/de.appplant.cordova.plugin.local-notification/www/local-notification.js",
"id": "de.appplant.cordova.plugin.local-notification.LocalNotification",
"clobbers": [
......@@ -57,6 +46,17 @@ module.exports = [
]
},
{
"file": "plugins/nl.x-services.plugins.toast/www/Toast.js",
"id": "nl.x-services.plugins.toast.Toast",
"clobbers": [
"window.plugins.toast"
]
},
{
"file": "plugins/nl.x-services.plugins.toast/test/tests.js",
"id": "nl.x-services.plugins.toast.tests"
},
{
"file": "plugins/org.apache.cordova.device/www/device.js",
"id": "org.apache.cordova.device.device",
"clobbers": [
......@@ -74,8 +74,8 @@ module.exports = [
module.exports.metadata =
// TOP OF METADATA
{
"nl.x-services.plugins.toast": "2.0.3",
"de.appplant.cordova.plugin.local-notification": "0.8.2dev",
"nl.x-services.plugins.toast": "2.0.3",
"org.apache.cordova.device": "0.3.0"
}
// BOTTOM OF METADATA
......
......@@ -200,7 +200,9 @@ exports.core = {
clearLocalNotification: function (id) {
var notification = this.getAll([id])[0];
this.getToastHistory().remove('Toast' + id);
try {
this.getToastHistory().remove('Toast' + id);
} catch (e) {/*Only Phones support the NotificationHistory*/ }
if (this.isRepeating(notification))
return;
......@@ -220,7 +222,9 @@ exports.core = {
this.clearLocalNotification(ids[i]);
}
this.getToastHistory().clear();
try {
this.getToastHistory().clear();
} catch (e) {/*Only Phones support the NotificationHistory*/ }
this.fireEvent('clearall');
},
......@@ -251,7 +255,9 @@ exports.core = {
history = this.getToastHistory(),
toasts = this.getScheduledToasts();
history.remove('Toast' + id);
try {
history.remove('Toast' + id);
} catch (e) {/*Only Phones support the NotificationHistory*/ }
for (var i = 0; i < toasts.length; i++) {
var toast = toasts[i];
......@@ -272,7 +278,9 @@ exports.core = {
this.cancelLocalNotification(ids[i]);
}
this.getToastHistory().clear();
try {
this.getToastHistory().clear();
} catch (e) {/*Only Phones support the NotificationHistory*/ }
this.fireEvent('cancelall');
},
......
......@@ -86,20 +86,52 @@ exports.isRepeating = function (notification) {
* @param {String} path
* Relative path to sound resource
*
* @return {String} URI to Sound-File
* @return {String} XML Tag for Sound-File
*/
exports.parseSound = function (path) {
if (!path.match(/^file/))
return '';
var uri = this.parseUri(path),
audio = "<audio src=" + uri + " loop='false'/>";
return audio;
};
/**
* Parses image file path.
*
* @param {String} path
* Relative path to image resource
*
* @return {String} XML-Tag for Image-File
*/
exports.parseImage = function (path) {
if (!path.match(/^file/))
return '';
var uri = this.parseUri(path),
image = "<image id='1' src=" + uri + " />";
return image;
};
/**
* Parses file path to URI.
*
* @param {String} path
* Relative path to a resource
*
* @return {String} URI to File
*/
exports.parseUri = function (path) {
var pkg = Windows.ApplicationModel.Package.current,
pkgId = pkg.id,
pkgName = pkgId.name;
if (!path.match(/^file/))
return;
var uri = "'ms-appx://" + pkgName + "/www" + path.slice(6, path.length) + "'";
var sound = "'ms-appx://" + pkgName + "/www/" + path.slice(6, path.length) + "'",
audio = "<audio src=" + sound + " loop='false'/>";
return audio;
return uri;
};
/**
......@@ -141,37 +173,47 @@ exports.build = function (options) {
* @return String
*/
exports.buildToastTemplate = function (options) {
var title = options.title,
message = options.text || '',
json = JSON.stringify(options),
sound = '';
if (options.sound && options.sound !== '') {
sound = this.parseSound(options.sound);
}
if (title && title !== '') {
return "<toast>" +
"<visual>" +
"<binding template='ToastText02'>" +
"<text id='1'>" + title + "</text>" +
"<text id='2'>" + message + "</text>" +
"</binding>" +
"</visual>" +
sound +
"<json>" + json + "</json>" +
"</toast>";
} else {
return "<toast>" +
"<visual>" +
"<binding template='ToastText01'>" +
"<text id='1'>" + message + "</text>" +
"</binding>" +
"</visual>" +
sound +
"<json>" + json + "</json>" +
"</toast>";
}
var title = options.title,
message = options.text || '',
json = JSON.stringify(options),
sound = '';
if (options.sound && options.sound !== '') {
sound = this.parseSound(options.sound);
}
var templateName = "ToastText",
imageNode;
if (options.icon && options.icon !== '') {
imageNode = this.parseImage(options.icon);
// template with Image
if (imageNode !== '') {
templateName = "ToastImageAndText";
};
} else {
imageNode = "";
}
var bindingNode;
if (title && title !== '') {
bindingNode = "<binding template='" + templateName + "02'>" +
imageNode +
"<text id='1'>" + title + "</text>" +
"<text id='2'>" + message + "</text>" +
"</binding>";
} else {
bindingNode = "<binding template='" + templateName + "01'>" +
imageNode +
"<text id='1'>" + message + "</text>" +
"</binding>";
}
return "<toast>" +
"<visual>" +
bindingNode +
"</visual>" +
sound +
"<json>" + json + "</json>" +
"</toast>";
};
/**
......
......@@ -275,7 +275,8 @@ exports.get = function () {
scope = args[2];
if (!Array.isArray(ids)) {
ids = [ids];
this.exec('getSingle', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
......@@ -321,6 +322,11 @@ exports.getScheduled = function () {
ids = [ids];
}
if (!Array.isArray(ids)) {
this.exec('getSingleScheduled', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
this.exec('getScheduled', ids, callback, scope);
......@@ -364,6 +370,11 @@ exports.getTriggered = function () {
ids = [ids];
}
if (!Array.isArray(ids)) {
this.exec('getSingleTriggered', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
this.exec('getTriggered', ids, callback, scope);
......
......@@ -59,6 +59,10 @@
{
"xml": "<uses-permission android:name=\"android.permission.RECEIVE_BOOT_COMPLETED\" />",
"count": 1
},
{
"xml": "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />",
"count": 1
}
]
}
......
......@@ -30,8 +30,8 @@ For example, applications that depend on servers for messages or data can poll t
The current 0.8 branch supports the following platforms:
- __iOS__ _(including iOS8)_<br>
- __Android__ _(SDK >=7)_
The partial support for WP8.0 has been dropped, but the Windows (Phone) 8.1 platform will be fully supported soon.
- __Windows 8.1__ _(added with v0.8.2)_
- __Windows Phone 8.1__ _(added with v0.8.2)_
Find out more informations [here][wiki_platforms] in our wiki.
......
......@@ -130,6 +130,7 @@
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</config-file>
<lib-file src="libs/android/android-support-v4.jar" />
......
#!/usr/bin/env node
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
......
#!/usr/bin/env node
// This Plugin-Hook sets ToastCapable on true to allow windows-platform
// cordova apps displaing local-notifications
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://opensource.org/licenses/Apache-2.0/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
// Includes a snippet into the cordova-core js file
// to fire the activated event after device is ready
var fs = require('fs'),
rootdir = process.argv[2];
......@@ -9,7 +34,17 @@ var fs = require('fs'),
if (!rootdir)
return;
function replace_string_in_file (filename, to_replace, replace_with) {
/**
* Replaces a string with another one in a file.
*
* @param {String} path
* Absolute or relative file path from cordova root project.
* @param {String} to_replace
* The string to replace.
* @param {String}
* The string to replace with.
*/
function replace (filename, to_replace, replace_with) {
var data = fs.readFileSync(filename, 'utf8'),
result;
......@@ -20,6 +55,7 @@ function replace_string_in_file (filename, to_replace, replace_with) {
fs.writeFileSync(filename, result, 'utf8');
}
// Fires the activated event again after device is ready
var snippet =
"var activatedHandler = function (args) {" +
"channel.deviceready.subscribe(function () {" +
......@@ -32,13 +68,13 @@ var snippet =
"}, false);\n" +
" app.start();";
// Path to cordova-core js files where the snippet needs to be included
var files = [
'platforms/windows/www/cordova.js',
'platforms/windows/platform_www/cordova.js'
];
// Includes the snippet before app.start() is called
for (var i = 0; i < files.length; i++) {
replace_string_in_file(files[i], 'app.start();', snippet);
replace(files[i], 'app.start();', snippet);
}
#!/usr/bin/env node
// This Plugin-Hook sets ToastCapable on true to allow windows-platform
// cordova apps displaing local-notifications
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://opensource.org/licenses/Apache-2.0/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
// Hook sets ToastCapable on true to enable local-notifications
var fs = require('fs'),
rootdir = process.argv[2];
......@@ -9,11 +33,21 @@ var fs = require('fs'),
if (!rootdir)
return;
function replace_string_in_file (filename, to_replace, replace_with) {
/**
* Replaces a string with another one in a file.
*
* @param {String} path
* Absolute or relative file path from cordova root project.
* @param {String} to_replace
* The string to replace.
* @param {String}
* The string to replace with.
*/
function replace (filename, to_replace, replace_with) {
var data = fs.readFileSync(filename, 'utf8'),
result;
if (data.indexOf(replace_with) > -1)
if (data.indexOf('ToastCapable') > -1)
return;
result = data.replace(new RegExp(to_replace, 'g'), replace_with);
......@@ -21,13 +55,9 @@ function replace_string_in_file (filename, to_replace, replace_with) {
fs.writeFileSync(filename, result, 'utf8');
}
var manifests = [
'platforms/windows/package.phone.appxmanifest',
'platforms/windows/package.windows.appxmanifest',
'platforms/windows/package.windows80.appxmanifest'
];
for (var i = 0; i < manifests.length; i++) {
replace_string_in_file(manifests[i], '<m3:VisualElements ', '<m3:VisualElements ToastCapable="true" ');
}
// Set ToastCapable for Windows Phone
replace('platforms/windows/package.phone.appxmanifest', '<m3:VisualElements', '<m3:VisualElements ToastCapable="true"');
// Set ToastCapable for Windows 8.1
replace('platforms/windows/package.windows.appxmanifest', '<m2:VisualElements', '<m2:VisualElements ToastCapable="true"');
// Set ToastCapable for Windows 8.0
replace('platforms/windows/package.windows80.appxmanifest', '<VisualElements', '<VisualElements ToastCapable="true"');
......@@ -174,6 +174,15 @@ public class LocalNotification extends CordovaPlugin {
else if (action.equals("getTriggeredIds")) {
getTriggeredIds(command);
}
else if (action.equals("getSingle")) {
getSingle(args, command);
}
else if (action.equals("getSingleScheduled")) {
getSingleScheduled(args, command);
}
else if (action.equals("getSingleTriggered")) {
getSingleTriggered(args, command);
}
else if (action.equals("getAll")) {
getAll(args, command);
}
......@@ -369,23 +378,51 @@ public class LocalNotification extends CordovaPlugin {
}
/**
* Set of options from local notification.
* Options from local notification.
*
* @param ids
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getAll (JSONArray ids, CallbackContext command) {
List<JSONObject> options;
private void getSingle (JSONArray ids, CallbackContext command) {
getOptions(ids.optString(0), Notification.Type.ALL, command);
}
if (ids.length() == 0) {
options = getNotificationMgr().getOptions();
} else {
options = getNotificationMgr().getOptionsById(toList(ids));
}
/**
* Options from scheduled notification.
*
* @param ids
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getSingleScheduled (JSONArray ids, CallbackContext command) {
getOptions(ids.optString(0), Notification.Type.SCHEDULED, command);
}
command.success(new JSONArray(options));
/**
* Options from triggered notification.
*
* @param ids
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getSingleTriggered (JSONArray ids, CallbackContext command) {
getOptions(ids.optString(0), Notification.Type.TRIGGERED, command);
}
/**
* Set of options from local notification.
*
* @param ids
* Set of local notification IDs
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getAll (JSONArray ids, CallbackContext command) {
getOptions(ids, Notification.Type.ALL, command);
}
/**
......@@ -397,16 +434,7 @@ public class LocalNotification extends CordovaPlugin {
* The callback context used when calling back into JavaScript.
*/
private void getScheduled (JSONArray ids, CallbackContext command) {
List<JSONObject> options;
if (ids.length() == 0) {
options = getNotificationMgr().getOptionsByType(Notification.Type.SCHEDULED);
} else {
options = getNotificationMgr().getOptionsBy(
Notification.Type.SCHEDULED, toList(ids));
}
command.success(new JSONArray(options));
getOptions(ids, Notification.Type.SCHEDULED, command);
}
/**
......@@ -418,13 +446,49 @@ public class LocalNotification extends CordovaPlugin {
* The callback context used when calling back into JavaScript.
*/
private void getTriggered (JSONArray ids, CallbackContext command) {
getOptions(ids, Notification.Type.TRIGGERED, command);
}
/**
* Options from local notification.
*
* @param id
* Set of local notification IDs
* @param type
* The local notification life cycle type
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getOptions (String id, Notification.Type type,
CallbackContext command) {
JSONArray ids = new JSONArray().put(id);
JSONObject options =
getNotificationMgr().getOptionsBy(type, toList(ids)).get(0);
command.success(options);
}
/**
* Set of options from local notifications.
*
* @param ids
* Set of local notification IDs
* @param type
* The local notification life cycle type
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getOptions (JSONArray ids, Notification.Type type,
CallbackContext command) {
List<JSONObject> options;
if (ids.length() == 0) {
options = getNotificationMgr().getOptionsByType(Notification.Type.TRIGGERED);
options = getNotificationMgr().getOptionsByType(type);
} else {
options = getNotificationMgr().getOptionsBy(
Notification.Type.TRIGGERED, toList(ids));
options = getNotificationMgr().getOptionsBy(type, toList(ids));
}
command.success(new JSONArray(options));
......
......@@ -48,7 +48,7 @@ import java.util.Set;
public class Manager {
// Context passed through constructor and used for notification builder.
private Context context;
private Context context;
/**
* Constructor
......@@ -56,9 +56,9 @@ public class Manager {
* @param context
* Application context
*/
private Manager(Context context){
this.context = context;
}
private Manager(Context context){
this.context = context;
}
/**
* Static method to retrieve class instance.
......@@ -256,6 +256,9 @@ public class Manager {
List<Notification> notifications = getAll();
ArrayList<Notification> list = new ArrayList<Notification>();
if (type == Notification.Type.ALL)
return notifications;
for (Notification notification : notifications) {
if (notification.getType() == type) {
list.add(notification);
......@@ -368,6 +371,9 @@ public class Manager {
public List<JSONObject> getOptionsBy(Notification.Type type,
List<Integer> ids) {
if (type == Notification.Type.ALL)
return getOptionsById(ids);
ArrayList<JSONObject> options = new ArrayList<JSONObject>();
List<Notification> notifications = getByIds(ids);
......
......@@ -46,7 +46,7 @@ public class Notification {
// Used to differ notifications by their life cycle state
public static enum Type {
SCHEDULED, TRIGGERED
ALL, SCHEDULED, TRIGGERED
}
// Default receiver to handle the trigger event
......
......@@ -200,7 +200,9 @@ exports.core = {
clearLocalNotification: function (id) {
var notification = this.getAll([id])[0];
this.getToastHistory().remove('Toast' + id);
try {
this.getToastHistory().remove('Toast' + id);
} catch (e) {/*Only Phones support the NotificationHistory*/ }
if (this.isRepeating(notification))
return;
......@@ -220,7 +222,9 @@ exports.core = {
this.clearLocalNotification(ids[i]);
}
this.getToastHistory().clear();
try {
this.getToastHistory().clear();
} catch (e) {/*Only Phones support the NotificationHistory*/ }
this.fireEvent('clearall');
},
......@@ -251,7 +255,9 @@ exports.core = {
history = this.getToastHistory(),
toasts = this.getScheduledToasts();
history.remove('Toast' + id);
try {
history.remove('Toast' + id);
} catch (e) {/*Only Phones support the NotificationHistory*/ }
for (var i = 0; i < toasts.length; i++) {
var toast = toasts[i];
......@@ -272,7 +278,9 @@ exports.core = {
this.cancelLocalNotification(ids[i]);
}
this.getToastHistory().clear();
try {
this.getToastHistory().clear();
} catch (e) {/*Only Phones support the NotificationHistory*/ }
this.fireEvent('cancelall');
},
......
......@@ -86,20 +86,52 @@ exports.isRepeating = function (notification) {
* @param {String} path
* Relative path to sound resource
*
* @return {String} URI to Sound-File
* @return {String} XML Tag for Sound-File
*/
exports.parseSound = function (path) {
if (!path.match(/^file/))
return '';
var uri = this.parseUri(path),
audio = "<audio src=" + uri + " loop='false'/>";
return audio;
};
/**
* Parses image file path.
*
* @param {String} path
* Relative path to image resource
*
* @return {String} XML-Tag for Image-File
*/
exports.parseImage = function (path) {
if (!path.match(/^file/))
return '';
var uri = this.parseUri(path),
image = "<image id='1' src=" + uri + " />";
return image;
};
/**
* Parses file path to URI.
*
* @param {String} path
* Relative path to a resource
*
* @return {String} URI to File
*/
exports.parseUri = function (path) {
var pkg = Windows.ApplicationModel.Package.current,
pkgId = pkg.id,
pkgName = pkgId.name;
if (!path.match(/^file/))
return;
var uri = "'ms-appx://" + pkgName + "/www" + path.slice(6, path.length) + "'";
var sound = "'ms-appx://" + pkgName + "/www/" + path.slice(6, path.length) + "'",
audio = "<audio src=" + sound + " loop='false'/>";
return audio;
return uri;
};
/**
......@@ -141,37 +173,47 @@ exports.build = function (options) {
* @return String
*/
exports.buildToastTemplate = function (options) {
var title = options.title,
message = options.text || '',
json = JSON.stringify(options),
sound = '';
if (options.sound && options.sound !== '') {
sound = this.parseSound(options.sound);
}
if (title && title !== '') {
return "<toast>" +
"<visual>" +
"<binding template='ToastText02'>" +
"<text id='1'>" + title + "</text>" +
"<text id='2'>" + message + "</text>" +
"</binding>" +
"</visual>" +
sound +
"<json>" + json + "</json>" +
"</toast>";
} else {
return "<toast>" +
"<visual>" +
"<binding template='ToastText01'>" +
"<text id='1'>" + message + "</text>" +
"</binding>" +
"</visual>" +
sound +
"<json>" + json + "</json>" +
"</toast>";
}
var title = options.title,
message = options.text || '',
json = JSON.stringify(options),
sound = '';
if (options.sound && options.sound !== '') {
sound = this.parseSound(options.sound);
}
var templateName = "ToastText",
imageNode;
if (options.icon && options.icon !== '') {
imageNode = this.parseImage(options.icon);
// template with Image
if (imageNode !== '') {
templateName = "ToastImageAndText";
};
} else {
imageNode = "";
}
var bindingNode;
if (title && title !== '') {
bindingNode = "<binding template='" + templateName + "02'>" +
imageNode +
"<text id='1'>" + title + "</text>" +
"<text id='2'>" + message + "</text>" +
"</binding>";
} else {
bindingNode = "<binding template='" + templateName + "01'>" +
imageNode +
"<text id='1'>" + message + "</text>" +
"</binding>";
}
return "<toast>" +
"<visual>" +
bindingNode +
"</visual>" +
sound +
"<json>" + json + "</json>" +
"</toast>";
};
/**
......
......@@ -275,7 +275,8 @@ exports.get = function () {
scope = args[2];
if (!Array.isArray(ids)) {
ids = [ids];
this.exec('getSingle', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
......@@ -321,6 +322,11 @@ exports.getScheduled = function () {
ids = [ids];
}
if (!Array.isArray(ids)) {
this.exec('getSingleScheduled', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
this.exec('getScheduled', ids, callback, scope);
......@@ -364,6 +370,11 @@ exports.getTriggered = function () {
ids = [ids];
}
if (!Array.isArray(ids)) {
this.exec('getSingleTriggered', ids.toString(), callback, scope);
return;
}
ids = this.convertIds(ids);
this.exec('getTriggered', ids, callback, scope);
......
......@@ -10,5 +10,11 @@
"type": "registry",
"id": "org.apache.cordova.device"
}
},
"de.appplant.cordova.plugin.email-composer": {
"source": {
"type": "local",
"path": "../cordova-plugin-email-composer"
}
}
}
\ No newline at end of file
......@@ -9,15 +9,15 @@
"parents": {
"/*": [
{
"xml": "<feature name=\"Device\"><param name=\"ios-package\" value=\"CDVDevice\" /></feature>",
"xml": "<feature name=\"Toast\"><param name=\"ios-package\" value=\"Toast\" /></feature>",
"count": 1
},
{
"xml": "<feature name=\"LocalNotification\"><param name=\"ios-package\" onload=\"true\" value=\"APPLocalNotification\" /><param name=\"onload\" value=\"true\" /></feature>",
"xml": "<feature name=\"Device\"><param name=\"ios-package\" value=\"CDVDevice\" /></feature>",
"count": 1
},
{
"xml": "<feature name=\"Toast\"><param name=\"ios-package\" value=\"Toast\" /></feature>",
"xml": "<feature name=\"LocalNotification\"><param name=\"ios-package\" onload=\"true\" value=\"APPLocalNotification\" /><param name=\"onload\" value=\"true\" /></feature>",
"count": 1
}
]
......@@ -30,16 +30,17 @@
"xml": false,
"count": 1
}
]
],
"MessageUI.framework": []
}
}
}
},
"installed_plugins": {
"de.appplant.cordova.plugin.local-notification": {
"nl.x-services.plugins.toast": {
"PACKAGE_NAME": "de.appplant.localnotification.example"
},
"nl.x-services.plugins.toast": {
"de.appplant.cordova.plugin.local-notification": {
"PACKAGE_NAME": "de.appplant.localnotification.example"
}
},
......
......@@ -7,10 +7,10 @@
"files": {}
},
"installed_plugins": {
"nl.x-services.plugins.toast": {
"de.appplant.cordova.plugin.local-notification": {
"PACKAGE_NAME": "NotificationExample"
},
"de.appplant.cordova.plugin.local-notification": {
"nl.x-services.plugins.toast": {
"PACKAGE_NAME": "NotificationExample"
}
},
......
......@@ -308,6 +308,7 @@
<!-- IDs -->
<script type="text/javascript">
var callbackIds = function (ids) {
console.log(ids);
showToast(ids.length === 0 ? '- none -' : ids.join(' ,'));
};
......@@ -331,8 +332,13 @@
showToast(notifications.length === 0 ? '- none -' : notifications.join(' ,'));
};
var callbackSingleOpts = function (notification) {
console.log(notification);
showToast(notification.toString());
};
get = function () {
cordova.plugins.notification.local.get(1, callbackOpts);
cordova.plugins.notification.local.get(1, callbackSingleOpts);
};
getMultiple = function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment