Commit 9578246d by Sebastián Katzer

CHANGE: New >foreground< option, false by default

Before on iOS all notification came up in foreground, thats different
now with this commit
parent c2ee2f84
......@@ -68,7 +68,8 @@ The plugin creates the object `cordova.plugins.notification.local` and is access
```js
cordova.plugins.notification.local.schedule({
title: 'My first notification',
text: 'Thats pretty easy...'
text: 'Thats pretty easy...',
foreground: true
});
```
......@@ -93,7 +94,7 @@ A notification does have a set of configurable properties. Not all of them are s
| :------------ | :------------ | :------------ | :------------ | :------------ | :------------ | :------------ | :------------ |
| id | data | actionGroupId | summary | led | showWhen | channel | actions |
| text | icon | attachments | smallIcon | color | defaults | launch | groupSummary |
| title | silent | progressBar | sticky | vibrate | priority | mediaSession |
| title | silent | progressBar | sticky | vibrate | priority | mediaSession | foreground |
| sound | trigger | group | autoClear | lockscreen | number | badge |
For their default values see:
......
......@@ -504,14 +504,18 @@
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
APPNotificationOptions* options = notification.request.options;
if (![notification.request wasUpdated]) {
[self fireEvent:@"trigger" notification:notification.request];
}
if (notification.request.options.silent) {
if (options.silent) {
completionHandler(UNNotificationPresentationOptionNone);
} else {
} else if (!isActive || options.priority > 0) {
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
} else {
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound);
}
}
......
......@@ -31,6 +31,7 @@
@property (readonly, getter=badge) NSNumber* badge;
@property (readonly, getter=text) NSString* text;
@property (readonly, getter=silent) BOOL silent;
@property (readonly, getter=priority) int priority;
@property (readonly, getter=sound) UNNotificationSound* sound;
@property (readonly, getter=userInfo) NSDictionary* userInfo;
@property (readonly, getter=actions) NSArray<UNNotificationAction *> * actions;
......
......@@ -115,7 +115,7 @@
}
/**
* Show notification in foreground.
* Show notification.
*
* @return [ BOOL ]
*/
......@@ -125,6 +125,16 @@
}
/**
* Show notification in foreground.
*
* @return [ BOOL ]
*/
- (int) priority
{
return [[dict objectForKey:@"priority"] intValue];
}
/**
* The badge number for the notification.
*
* @return [ NSNumber* ]
......
......@@ -33,6 +33,7 @@ exports._defaults = {
color : null,
data : null,
defaults : 0,
foreground : false,
group : null,
groupSummary : false,
icon : null,
......@@ -127,6 +128,14 @@ exports.convertProperties = function (options) {
options.priority = parseToInt('priority', options);
}
if (options.foreground === true) {
options.priority = Math.max(options.priority, 1);
}
if (options.foreground === false) {
options.priority = Math.min(options.priority, 0);
}
if (options.defaults) {
options.defaults = parseToInt('defaults', options);
}
......
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