commit
3693121c86
|
@ -129,7 +129,7 @@
|
||||||
<plugin name="cordova-plugin-globalization" spec="^1.11.0" />
|
<plugin name="cordova-plugin-globalization" spec="^1.11.0" />
|
||||||
<plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
|
<plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
|
||||||
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.1.3" />
|
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.1.3" />
|
||||||
<plugin name="cordova-plugin-local-notification" spec="0.9.0-beta.3" />
|
<plugin name="cordova-plugin-local-notification" spec="https://github.com/moodlemobile/cordova-plugin-local-notifications.git#moodle" />
|
||||||
<plugin name="cordova-plugin-media-capture" spec="^3.0.2" />
|
<plugin name="cordova-plugin-media-capture" spec="^3.0.2" />
|
||||||
<plugin name="cordova-plugin-network-information" spec="^2.0.1" />
|
<plugin name="cordova-plugin-network-information" spec="^2.0.1" />
|
||||||
<plugin name="cordova-plugin-screen-orientation" spec="^3.0.1" />
|
<plugin name="cordova-plugin-screen-orientation" spec="^3.0.1" />
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
<plugin name="cordova-plugin-zip" spec="^3.1.0" />
|
<plugin name="cordova-plugin-zip" spec="^3.1.0" />
|
||||||
<plugin name="cordova-sqlite-storage" spec="^2.6.0" />
|
<plugin name="cordova-sqlite-storage" spec="^2.6.0" />
|
||||||
<plugin name="nl.kingsquare.cordova.background-audio" spec="^1.0.1" />
|
<plugin name="nl.kingsquare.cordova.background-audio" spec="^1.0.1" />
|
||||||
<plugin name="phonegap-plugin-push" spec="https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v2">
|
<plugin name="phonegap-plugin-push" spec="https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v3">
|
||||||
<variable name="ANDROID_SUPPORT_V13_VERSION" value="27.+" />
|
<variable name="ANDROID_SUPPORT_V13_VERSION" value="27.+" />
|
||||||
<variable name="FCM_VERSION" value="17.0.+" />
|
<variable name="FCM_VERSION" value="17.0.+" />
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -3173,9 +3173,8 @@
|
||||||
"integrity": "sha512-6ucQ6FdlLdBm8kJfFnzozmBTjru/0xekHP/dAhjoCZggkGRlgs8TsUJFkxa/bV+qi7Dlo50JjmpE4UMWAO+aOQ=="
|
"integrity": "sha512-6ucQ6FdlLdBm8kJfFnzozmBTjru/0xekHP/dAhjoCZggkGRlgs8TsUJFkxa/bV+qi7Dlo50JjmpE4UMWAO+aOQ=="
|
||||||
},
|
},
|
||||||
"cordova-plugin-local-notification": {
|
"cordova-plugin-local-notification": {
|
||||||
"version": "0.9.0-beta.3",
|
"version": "git+https://github.com/moodlemobile/cordova-plugin-local-notifications.git#5b2f3073a1c1fb39cad3566be792445c343db2c6",
|
||||||
"resolved": "https://registry.npmjs.org/cordova-plugin-local-notification/-/cordova-plugin-local-notification-0.9.0-beta.3.tgz",
|
"from": "git+https://github.com/moodlemobile/cordova-plugin-local-notifications.git#moodle"
|
||||||
"integrity": "sha512-L3Z1velxrkm9nHFcvLnMgBPZjKFt6hwM6hn1lA+JFwIR26Yw6UF72z+/lRMBclAcOxBIDYCqeaLgvezmajjuEg=="
|
|
||||||
},
|
},
|
||||||
"cordova-plugin-media-capture": {
|
"cordova-plugin-media-capture": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
|
@ -3600,7 +3599,7 @@
|
||||||
},
|
},
|
||||||
"readable-stream": {
|
"readable-stream": {
|
||||||
"version": "1.1.14",
|
"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=",
|
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -5972,7 +5971,7 @@
|
||||||
},
|
},
|
||||||
"chalk": {
|
"chalk": {
|
||||||
"version": "1.1.3",
|
"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=",
|
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -8575,8 +8574,8 @@
|
||||||
"integrity": "sha512-1wvc3iQOQpEBaQbXgLxA2JUiLSQ2azdF/bF29ghXDiQJWSpQ1BF8gSuqttM8WZoj081Ps8OKL0gYxdDBkFNPqA=="
|
"integrity": "sha512-1wvc3iQOQpEBaQbXgLxA2JUiLSQ2azdF/bF29ghXDiQJWSpQ1BF8gSuqttM8WZoj081Ps8OKL0gYxdDBkFNPqA=="
|
||||||
},
|
},
|
||||||
"phonegap-plugin-push": {
|
"phonegap-plugin-push": {
|
||||||
"version": "git+https://github.com/moodlemobile/phonegap-plugin-push.git#b2fb84bab47d2a86e934893394d8667eec82f0e8",
|
"version": "git+https://github.com/moodlemobile/phonegap-plugin-push.git#cf8101e86adb774ae1d7ad6b65fb9d8802673f4b",
|
||||||
"from": "git+https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v2",
|
"from": "git+https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v3",
|
||||||
"requires": {
|
"requires": {
|
||||||
"babel-plugin-add-header-comment": "^1.0.3",
|
"babel-plugin-add-header-comment": "^1.0.3",
|
||||||
"install": "^0.8.2"
|
"install": "^0.8.2"
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
"cordova-plugin-globalization": "^1.11.0",
|
"cordova-plugin-globalization": "^1.11.0",
|
||||||
"cordova-plugin-inappbrowser": "^3.0.0",
|
"cordova-plugin-inappbrowser": "^3.0.0",
|
||||||
"cordova-plugin-ionic-keyboard": "^2.1.3",
|
"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-media-capture": "^3.0.2",
|
||||||
"cordova-plugin-network-information": "^2.0.1",
|
"cordova-plugin-network-information": "^2.0.1",
|
||||||
"cordova-plugin-screen-orientation": "^3.0.1",
|
"cordova-plugin-screen-orientation": "^3.0.1",
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
"moment": "^2.22.2",
|
"moment": "^2.22.2",
|
||||||
"nl.kingsquare.cordova.background-audio": "^1.0.1",
|
"nl.kingsquare.cordova.background-audio": "^1.0.1",
|
||||||
"phonegap-plugin-multidex": "^1.0.0",
|
"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",
|
"promise.prototype.finally": "^3.1.0",
|
||||||
"rxjs": "^5.5.11",
|
"rxjs": "^5.5.11",
|
||||||
"sw-toolbox": "^3.6.0",
|
"sw-toolbox": "^3.6.0",
|
||||||
|
|
|
@ -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 the app is in foreground when the notification is received, it's not shown. Let's show it ourselves.
|
||||||
if (this.localNotificationsProvider.isAvailable()) {
|
if (this.localNotificationsProvider.isAvailable()) {
|
||||||
const localNotif: ILocalNotification = {
|
const localNotif: ILocalNotification = {
|
||||||
id: 1,
|
id: data.notId || 1,
|
||||||
data: data,
|
data: data,
|
||||||
title: '',
|
title: '',
|
||||||
text: ''
|
text: '',
|
||||||
|
channel: 'PushPluginChannel'
|
||||||
},
|
},
|
||||||
promises = [];
|
promises = [],
|
||||||
|
extraFeatures = this.utils.isTrueOrOne(data.extrafeatures);
|
||||||
|
|
||||||
// Apply formatText to title and message.
|
// Apply formatText to title and message.
|
||||||
promises.push(this.textUtils.formatText(notification.title, true, true).then((formattedTitle) => {
|
promises.push(this.textUtils.formatText(notification.title, true, true).then((formattedTitle) => {
|
||||||
|
@ -332,14 +334,33 @@ export class CorePushNotificationsProvider {
|
||||||
localNotif.title = notification.title;
|
localNotif.title = notification.title;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
promises.push(this.textUtils.formatText(notification.message, true, true).then((formattedMessage) => {
|
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.
|
||||||
|
(<any> localNotif).text = [
|
||||||
|
{
|
||||||
|
message: formattedMessage,
|
||||||
|
person: data.conversationtype == 2 ? data.userfromfullname : ''
|
||||||
|
}
|
||||||
|
];
|
||||||
|
} else {
|
||||||
localNotif.text = formattedMessage;
|
localNotif.text = formattedMessage;
|
||||||
}).catch(() => {
|
}
|
||||||
localNotif.text = notification.message;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
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.
|
||||||
|
(<any> localNotif).iconType = data['image-type'];
|
||||||
|
}
|
||||||
|
|
||||||
Promise.all(promises).then(() => {
|
Promise.all(promises).then(() => {
|
||||||
this.localNotificationsProvider.schedule(localNotif, CorePushNotificationsProvider.COMPONENT, data.site);
|
this.localNotificationsProvider.schedule(localNotif, CorePushNotificationsProvider.COMPONENT, data.site,
|
||||||
|
true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -470,10 +470,19 @@ export class CoreLocalNotificationsProvider {
|
||||||
* be unique inside its component and site.
|
* be unique inside its component and site.
|
||||||
* @param {string} component Component triggering the notification. It is used to generate unique IDs.
|
* @param {string} component Component triggering the notification. It is used to generate unique IDs.
|
||||||
* @param {string} siteId Site ID.
|
* @param {string} siteId Site ID.
|
||||||
|
* @param {boolean} [alreadyUnique] Whether the ID is already unique.
|
||||||
* @return {Promise<any>} Promise resolved when the notification is scheduled.
|
* @return {Promise<any>} Promise resolved when the notification is scheduled.
|
||||||
*/
|
*/
|
||||||
schedule(notification: ILocalNotification, component: string, siteId: string): Promise<any> {
|
schedule(notification: ILocalNotification, component: string, siteId: string, alreadyUnique?: boolean): Promise<any> {
|
||||||
return this.getUniqueNotificationId(notification.id, component, siteId).then((uniqueId) => {
|
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.id = uniqueId;
|
||||||
notification.data = notification.data || {};
|
notification.data = notification.data || {};
|
||||||
notification.data.component = component;
|
notification.data.component = component;
|
||||||
|
|
Loading…
Reference in New Issue