Skip to content

Commit

Permalink
fix(windows)!: remove deprecated platform (#245)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexandre Alves <aalves@seamlink.com>
  • Loading branch information
seamlink-aalves and Alexandre Alves committed Oct 1, 2023
1 parent 29941f6 commit 45d65b1
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 213 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ overrides:
extends: '@cordova/eslint-config/node-tests'
rules:
indent: ["error", 2]

- files: [src/windows/**/*.js]
globals:
Windows: true
1 change: 0 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"ecosystem:phonegap",
"cordova-ios",
"cordova-android",
"cordova-windows",
"cordova-browser"
],
"homepage": "https://github.com/phonegap/phonegap-plugin-push",
Expand Down
16 changes: 7 additions & 9 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@
- [push.unsubscribe(topic, successHandler, errorHandler)](#pushunsubscribetopic-successhandler-errorhandler)
- [Parameters](#parameters-9)
- [Example](#example-11)
- [push.setApplicationIconBadgeNumber(successHandler, errorHandler, count) - iOS & Android only](#pushsetapplicationiconbadgenumbersuccesshandler-errorhandler-count---ios--android-only)
- [push.setApplicationIconBadgeNumber(successHandler, errorHandler, count) - iOS \& Android only](#pushsetapplicationiconbadgenumbersuccesshandler-errorhandler-count---ios--android-only)
- [Parameters](#parameters-10)
- [Example](#example-12)
- [push.getApplicationIconBadgeNumber(successHandler, errorHandler) - iOS & Android only](#pushgetapplicationiconbadgenumbersuccesshandler-errorhandler---ios--android-only)
- [push.getApplicationIconBadgeNumber(successHandler, errorHandler) - iOS \& Android only](#pushgetapplicationiconbadgenumbersuccesshandler-errorhandler---ios--android-only)
- [Parameters](#parameters-11)
- [Callback parameters](#callback-parameters-5)
- [`successHandler`](#successhandler-2)
- [Example](#example-13)
- [push.finish(successHandler, errorHandler, id) - iOS only](#pushfinishsuccesshandler-errorhandler-id---ios-only)
- [Parameters](#parameters-12)
- [Example](#example-14)
- [push.clearAllNotifications(successHandler, errorHandler) - iOS & Android only](#pushclearallnotificationssuccesshandler-errorhandler---ios--android-only)
- [push.clearAllNotifications(successHandler, errorHandler) - iOS \& Android only](#pushclearallnotificationssuccesshandler-errorhandler---ios--android-only)
- [Parameters](#parameters-13)
- [Example](#example-15)
- [push.clearNotification(id, successHandler, errorHandler) - iOS & Android only](#pushclearnotificationid-successhandler-errorhandler---ios--android-only)
- [push.clearNotification(id, successHandler, errorHandler) - iOS \& Android only](#pushclearnotificationid-successhandler-errorhandler---ios--android-only)
- [Parameters](#parameters-14)
- [Example](#example-16)

Expand All @@ -89,7 +89,7 @@ Initializes the plugin on the native side.
| --------- | -------- | ------- | ------------------------------------------------------------------------ |
| `options` | `Object` | `{}` | An object describing relevant specific options for all target platforms. |

All available option attributes are described bellow. Currently, there are no Windows specific options.
All available option attributes are described bellow.

#### Android

Expand Down Expand Up @@ -199,8 +199,7 @@ const push = PushNotification.init({
alert: 'true',
badge: true,
sound: 'false'
},
windows: {}
}
});
```

Expand Down Expand Up @@ -388,10 +387,9 @@ The event `notification` will be triggered each time a push notification is rece
| -------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `data.message` | `string` | The text of the push message sent from the 3rd party service. |
| `data.title` | `string` | The optional title of the push message sent from the 3rd party service. |
| `data.count` | `string` | The number of messages to be displayed in the badge in iOS/Android or message count in the notification shade in Android. For windows, it represents the value in the badge notification which could be a number or a status glyph. |
| `data.count` | `string` | The number of messages to be displayed in the badge in iOS/Android or message count in the notification shade in Android. |
| `data.sound` | `string` | The name of the sound file to be played upon receipt of the notification. |
| `data.image` | `string` | The path of the image file to be displayed in the notification. |
| `data.launchArgs` | `string` | The args to be passed to the application on launch from push notification. This works when notification is received in background. (Windows Only) |
| `data.additionalData` | `Object` | An optional collection of data sent by the 3rd party push service that does not fit in the above properties. |
| `data.additionalData.foreground` | `boolean` | Whether the notification was received while the app was in the foreground |
| `data.additionalData.coldstart` | `boolean` | Will be `true` if the application is started by clicking on the push notification, `false` if the app is already started. |
Expand Down
3 changes: 1 addition & 2 deletions docs/EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const push = PushNotification.init({
alert: "true",
badge: "true",
sound: "true"
},
windows: {}
}
});

push.on('registration', (data) => {
Expand Down
54 changes: 2 additions & 52 deletions docs/PAYLOAD.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
- [FCM and Additional Data](#fcm-and-additional-data)
- [FCM Messages Not Arriving](#fcm-messages-not-arriving)
- [FCM Payload Details](#fcm-payload-details)
- [Windows Behaviour](#windows-behaviour)
- [Notifications](#notifications)
- [Setting Toast Capable Option for Windows](#setting-toast-capable-option-for-windows)
- [Disabling the default processing of notifications by Windows](#disabling-the-default-processing-of-notifications-by-windows)
- [Background Notifications](#background-notifications-2)

# Overview

Expand Down Expand Up @@ -412,8 +407,7 @@ const push = PushNotification.init({
alert: 'true',
badge: 'true',
sound: 'true'
},
windows: {}
}
});
```

Expand Down Expand Up @@ -453,8 +447,7 @@ const push = PushNotification.init({
alert: 'true',
badge: 'true',
sound: 'true'
},
windows: {}
}
});
```

Expand Down Expand Up @@ -2198,46 +2191,3 @@ More information on how to send push notifications using the FCM HTTP protocol a
- [Send messages using the legacy app server protocols](https://firebase.google.com/docs/cloud-messaging/send-message#send_messages_using_the_legacy_app_server_protocols 'Send messages using the legacy app server protocols')
- [Firebase Cloud Messaging HTTP Protocol](https://firebase.google.com/docs/cloud-messaging/http-server-ref 'Firebase Cloud Messaging HTTP Protocol')
# Windows Behaviour
## Notifications
The plugin supports all types of windows platform notifications namely [Tile, Toast, Badge and Raw](https://msdn.microsoft.com/en-us/library/windows/apps/Hh779725.aspx). The API supports the basic cases of the notification templates with title corresponding to the first text element and message corresponding to the second if title is present else the first one. The image corresponds to the first image element of the notification xml.
The count is present only for the badge notification in which it represent the value of the notification which could be a number from 0-99 or a status glyph.
For advanced templates and usage, the notification object is included in [`data.additionalData.pushNotificationReceivedEventArgs`](https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.pushnotifications.pushnotificationreceivedeventargs).
## Setting Toast Capable Option for Windows
This plugin automatically sets the toast capable flag to be true for Cordova 5.1.1+. For lower versions, you must declare that it is Toast Capable in your app's manifest file.
## Disabling the default processing of notifications by Windows
The default handling can be disabled by setting the 'cancel' property in the notification object.
```javascript
data.additionalData.pushNotificationReceivedEventArgs.cancel = true;
```
## Background Notifications
On Windows, to trigger the on('notification') event handler when your app is in the background and it is launched through the push notification, you will have to include `activation` data in the payload of the notification. This is done by using the `launch` attribute, which can be any string that can be understood by the app. However it should not cause the XML payload to become invalid.
If you do not include a launch attribute string, your app will be launched normally, as though the user had launched it from the Start screen, and the notification event handler won't be called.
Here is an example of a sample toast notification payload containing the launch attribute:
```xml
<toast launch="{&quot;myContext&quot;:&quot;12345&quot;}">
<visual>
<binding template="ToastImageAndText01">
<image id="1" src="ms-appx:///images/redWide.png" alt="red graphic"/>
<text id="1">Hello World!</text>
</binding>
</visual>
</toast>
```
This launch attribute string is passed on to the app as data.launchArgs through the on('notification') handler. It's important to note that due to the Windows platform design, the other visual payload is not available to the handler on cold start. Notification attributes like message, title, etc., are available through the on('notification') handler when the app is running, and won't be available for background notifications.
1 change: 0 additions & 1 deletion docs/PLATFORM_SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
- Android (`cordova-android` 12.0.0 or higher)
- Browser
- iOS (`cordova-ios` 6.0.0 or higher)
- Windows Universal (not Windows Phone 8)

### Version 3.x.x

Expand Down
3 changes: 1 addition & 2 deletions docs/TYPESCRIPT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ const push = PushNotification.init({
alert: "true",
badge: true,
sound: 'false'
},
windows: {}
}
});

push.on('registration', (data) => {
Expand Down
18 changes: 0 additions & 18 deletions hooks/windows/setToastCapable.js

This file was deleted.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"ecosystem:cordova",
"cordova-ios",
"cordova-android",
"cordova-windows",
"cordova-browser"
],
"author": "Erisu",
Expand Down Expand Up @@ -66,7 +65,6 @@
"platforms": [
"ios",
"android",
"windows",
"browser"
]
}
Expand Down
13 changes: 1 addition & 12 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
id="@havesource/cordova-plugin-push" version="4.0.0-dev.0">

<name>Cordova Push Plugin</name>
<description>Enable receiving push notifications on Android, iOS and Windows devices. Android uses Firebase Cloud Messaging. iOS uses Apple APNS Notifications. Windows uses Microsoft WNS Notifications.</description>
<description>Enable receiving push notifications on Android and iOS devices. Android uses Firebase Cloud Messaging. iOS uses Apple APNS Notifications.</description>

<license>MIT</license>

Expand Down Expand Up @@ -132,15 +132,4 @@
</podspec>
</platform>

<platform name="windows">
<hook type="after_plugin_install" src="hooks/windows/setToastCapable.js"/>

<js-module src="src/windows/PushPluginProxy.js" name="PushPlugin">
<runs/>
</js-module>

<config-file target="config.xml" parent="/*">
<preference name="WindowsToastCapable" value="true"/>
</config-file>
</platform>
</plugin>
2 changes: 1 addition & 1 deletion spec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let options;

describe('phonegap-plugin-push', () => {
beforeEach(() => {
options = { android: {}, ios: {}, windows: {} };
options = { android: {}, ios: {} };
execWin = jasmine.createSpy();
execSpy = spyOn(cordova.required, 'cordova/exec').and.callFake(execWin);
});
Expand Down
101 changes: 0 additions & 101 deletions src/windows/PushPluginProxy.js

This file was deleted.

8 changes: 0 additions & 8 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,6 @@ declare namespace PhonegapPluginPush {
*/
topics?: string[]
}

/**
* Windows specific initialization options.
*/
windows?: {

}
}

interface CategoryArray {
Expand Down Expand Up @@ -273,7 +266,6 @@ declare namespace PhonegapPluginPush {
title?: string
/**
* The number of messages to be displayed in the badge iOS or message count in the notification shade in Android.
* For windows, it represents the value in the badge notification which could be a number or a status glyph.
*/
count: string
/**
Expand Down

0 comments on commit 45d65b1

Please sign in to comment.