diff --git a/config.xml b/config.xml
index 4b3c43d65..ad5096d54 100644
--- a/config.xml
+++ b/config.xml
@@ -129,7 +129,7 @@
-
+
@@ -139,7 +139,7 @@
-
+
diff --git a/package-lock.json b/package-lock.json
index efde4ebc4..4e89f7b0c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3173,9 +3173,8 @@
"integrity": "sha512-6ucQ6FdlLdBm8kJfFnzozmBTjru/0xekHP/dAhjoCZggkGRlgs8TsUJFkxa/bV+qi7Dlo50JjmpE4UMWAO+aOQ=="
},
"cordova-plugin-local-notification": {
- "version": "0.9.0-beta.3",
- "resolved": "https://registry.npmjs.org/cordova-plugin-local-notification/-/cordova-plugin-local-notification-0.9.0-beta.3.tgz",
- "integrity": "sha512-L3Z1velxrkm9nHFcvLnMgBPZjKFt6hwM6hn1lA+JFwIR26Yw6UF72z+/lRMBclAcOxBIDYCqeaLgvezmajjuEg=="
+ "version": "git+https://github.com/moodlemobile/cordova-plugin-local-notifications.git#5b2f3073a1c1fb39cad3566be792445c343db2c6",
+ "from": "git+https://github.com/moodlemobile/cordova-plugin-local-notifications.git#moodle"
},
"cordova-plugin-media-capture": {
"version": "3.0.2",
@@ -3600,7 +3599,7 @@
},
"readable-stream": {
"version": "1.1.14",
- "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
+ "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"dev": true,
"requires": {
@@ -5972,7 +5971,7 @@
},
"chalk": {
"version": "1.1.3",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
+ "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"dev": true,
"requires": {
@@ -8575,8 +8574,8 @@
"integrity": "sha512-1wvc3iQOQpEBaQbXgLxA2JUiLSQ2azdF/bF29ghXDiQJWSpQ1BF8gSuqttM8WZoj081Ps8OKL0gYxdDBkFNPqA=="
},
"phonegap-plugin-push": {
- "version": "git+https://github.com/moodlemobile/phonegap-plugin-push.git#b2fb84bab47d2a86e934893394d8667eec82f0e8",
- "from": "git+https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v2",
+ "version": "git+https://github.com/moodlemobile/phonegap-plugin-push.git#cf8101e86adb774ae1d7ad6b65fb9d8802673f4b",
+ "from": "git+https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v3",
"requires": {
"babel-plugin-add-header-comment": "^1.0.3",
"install": "^0.8.2"
diff --git a/package.json b/package.json
index ee9784dba..0c5fc0d62 100644
--- a/package.json
+++ b/package.json
@@ -93,7 +93,7 @@
"cordova-plugin-globalization": "^1.11.0",
"cordova-plugin-inappbrowser": "^3.0.0",
"cordova-plugin-ionic-keyboard": "^2.1.3",
- "cordova-plugin-local-notification": "0.9.0-beta.3",
+ "cordova-plugin-local-notification": "git+https://github.com/moodlemobile/cordova-plugin-local-notifications.git#moodle",
"cordova-plugin-media-capture": "^3.0.2",
"cordova-plugin-network-information": "^2.0.1",
"cordova-plugin-screen-orientation": "^3.0.1",
@@ -111,7 +111,7 @@
"moment": "^2.22.2",
"nl.kingsquare.cordova.background-audio": "^1.0.1",
"phonegap-plugin-multidex": "^1.0.0",
- "phonegap-plugin-push": "git+https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v2",
+ "phonegap-plugin-push": "git+https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v3",
"promise.prototype.finally": "^3.1.0",
"rxjs": "^5.5.11",
"sw-toolbox": "^3.6.0",
diff --git a/src/core/pushnotifications/providers/pushnotifications.ts b/src/core/pushnotifications/providers/pushnotifications.ts
index 108f43601..de508f430 100644
--- a/src/core/pushnotifications/providers/pushnotifications.ts
+++ b/src/core/pushnotifications/providers/pushnotifications.ts
@@ -318,12 +318,14 @@ export class CorePushNotificationsProvider {
// If the app is in foreground when the notification is received, it's not shown. Let's show it ourselves.
if (this.localNotificationsProvider.isAvailable()) {
const localNotif: ILocalNotification = {
- id: 1,
+ id: data.notId || 1,
data: data,
title: '',
- text: ''
+ text: '',
+ channel: 'PushPluginChannel'
},
- promises = [];
+ promises = [],
+ extraFeatures = this.utils.isTrueOrOne(data.extrafeatures);
// Apply formatText to title and message.
promises.push(this.textUtils.formatText(notification.title, true, true).then((formattedTitle) => {
@@ -332,14 +334,33 @@ export class CorePushNotificationsProvider {
localNotif.title = notification.title;
}));
- promises.push(this.textUtils.formatText(notification.message, true, true).then((formattedMessage) => {
- localNotif.text = formattedMessage;
- }).catch(() => {
- localNotif.text = notification.message;
+ promises.push(this.textUtils.formatText(notification.message, true, true).catch(() => {
+ // Error formatting, use the original message.
+ return notification.message;
+ }).then((formattedMessage) => {
+ if (extraFeatures && this.utils.isFalseOrZero(data.notif)) {
+ // It's a message, use messaging style. Ionic Native doesn't specify this option.
+ ( localNotif).text = [
+ {
+ message: formattedMessage,
+ person: data.conversationtype == 2 ? data.userfromfullname : ''
+ }
+ ];
+ } else {
+ localNotif.text = formattedMessage;
+ }
}));
+ if (extraFeatures) {
+ // Use a different icon if needed.
+ localNotif.icon = notification.image;
+ // This feature isn't supported by the official plugin, we use a fork.
+ ( localNotif).iconType = data['image-type'];
+ }
+
Promise.all(promises).then(() => {
- this.localNotificationsProvider.schedule(localNotif, CorePushNotificationsProvider.COMPONENT, data.site);
+ this.localNotificationsProvider.schedule(localNotif, CorePushNotificationsProvider.COMPONENT, data.site,
+ true);
});
}
diff --git a/src/providers/local-notifications.ts b/src/providers/local-notifications.ts
index de8e89e94..036803306 100644
--- a/src/providers/local-notifications.ts
+++ b/src/providers/local-notifications.ts
@@ -470,10 +470,19 @@ export class CoreLocalNotificationsProvider {
* be unique inside its component and site.
* @param {string} component Component triggering the notification. It is used to generate unique IDs.
* @param {string} siteId Site ID.
+ * @param {boolean} [alreadyUnique] Whether the ID is already unique.
* @return {Promise} Promise resolved when the notification is scheduled.
*/
- schedule(notification: ILocalNotification, component: string, siteId: string): Promise {
- return this.getUniqueNotificationId(notification.id, component, siteId).then((uniqueId) => {
+ schedule(notification: ILocalNotification, component: string, siteId: string, alreadyUnique?: boolean): Promise {
+ let promise;
+
+ if (alreadyUnique) {
+ promise = Promise.resolve(notification.id);
+ } else {
+ promise = this.getUniqueNotificationId(notification.id, component, siteId);
+ }
+
+ return promise.then((uniqueId) => {
notification.id = uniqueId;
notification.data = notification.data || {};
notification.data.component = component;