Closed voidbrain closed 6 years ago
iOS has some internal limits for how many notifications you can schedule.
yes but what is this (number, I suppose) limit? I remember there was a limit with older versions of iOS but for what I understand it had been removed time ago.
When I set notifications there is no feedback about the correct or failed set up and also I cannot see difference between a failed and a correct set up.
If I query the notifications list after the set up it is correct, also if N = 60 or more. So, why it is considered in some cases and not in others?
So how can I understand if notifications will work or not?
@voidbrain There's actually no way through the plugin to get immediate feedback if a notification could be scheduled because the way differs to much between different mobile platforms.
We count the number of notifications we have scheduled to make sure we never get near the limit. Possibly easier for us as we don't schedule hundreds in advance. However we do check what we have scheduled and manage future notifications accordingly.
The limit for iOS is around 64 - there's no error if you schedule more. The system keeps the soonest-firing 64 notifications. However thats internal behaviour and not under control by the plugin.
I also wont ask why you're scheduling 45+ notifications in advance. You will know why however thats not favoured by iOS/Apple.
I had the same issue here. My coworker tested my app on a iOS Device and didn't get any notifications there. Finally (and with the help of that issue here), i resolved the problem as i maximum schedule now 64 Notifications and not more. If you schedule more than 64 Notifications, the Notifications will not work any longer.
@katzer
I used the following JS to avoid the problem:
// Warning for iOS, only the first 64 Notifications will be scheduled.
// see: https://developer.apple.com/documentation/uikit/uilocalnotification
if(notificationsData.length > 64) {
console.warn("Under iOS, only the first 64 Notifications will be used, the rest will be discarded");
// Shorten array to 64 elements
notificationsData = notificationsData.slice(0, 64);
}
@katzer With my sample code i only wanted to indicate, that you could add a warning message for iOS, if the user schedules more than 64 Notifications. Because, the Notifications will not work anymore, if you schedule more than 64.
@GitToTheHub I will add a hint on the README however the limit is different for every OS and in case of Android for every manufacturer. Adding a runtime check slows down the code to much as the plugin need to load all notifications first before scheduling an additional one.
Ok, you are right, its very expensive to load all notifications first, to add then another notification. A hint in the readme would be really good :) You wrote, that there can be a limit on Android. I thought always, there is no limit for Notifications. These are news for me :)
I have Array of notifications, when I set them (and I see them when I query them with
getAll()
) but notifications does not appear. The original length of the array was 60. It started working when I changed to 45.Your Environment
Plugin version: both on 0.8.5 and 0.9
Platform: MacOS High Sierra 10.13.2
OS version 11.2.5:
Device manufacturer / model: Apple iPhone 8
Cordova version (
cordova -v
): 8.0.0Cordova platform version (
cordova platform ls
): browser ~5.0.1 osx ~4.0.1 windows ~5.0.0 www ^3.12.0Plugin config cordova-plugin-add-swift-support 1.7.1 "AddSwiftSupport" cordova-plugin-app-event 1.2.1 "Application Events" cordova-plugin-app-version 0.1.9 "AppVersion" cordova-plugin-device 1.1.4 "Device" cordova-plugin-geolocation 3.0.0 "Geolocation" cordova-plugin-inappbrowser 1.7.2 "InAppBrowser" cordova-plugin-ionic 2.0.4 "IonicCordova" cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview" cordova-plugin-network-information 2.0.1 "Network Information" cordova-plugin-splashscreen 4.0.3 "Splashscreen" cordova-plugin-statusbar 2.4.1 "StatusBar" cordova-plugin-whitelist 1.3.1 "Whitelist" de.appplant.cordova.plugin.local-notification 0.8.5 "LocalNotification" ionic-plugin-keyboard 2.2.1 "Keyboard"
Ionic Version (if using Ionic) 3.19.1 (but also with a just-cordovan app )
Expected Behavior
trigger the notifications Tell us what should happen notifications should be triggered
Actual Behavior
notifications are not triggered (if length=60 no notification at all, if length=45 it works)
Tell us what happens instead
Steps to Reproduce
Reproduce this issue; include code to reproduce, if relevant
` for(let day in calendario){ let notification = { id: dayrow["id"], title: 'Calendario svuotamenti'+" "+(row["zona"]?row["zona"]:row["comune"]), text: 'Domani: ' + notificationText, at: new Date( notificationTimeDate.year(), notificationTimeDate.month(), notificationTimeDate.date(), notificationTimeDate.hour(), notificationTimeDate.minute(), ), }; this.notifications.push(notification); } this.notifications.sort((a, b) => a.at < b.at ? -1 : a.at > b.at ? 1 : 0) let maxNotificationsNumber = 45; // 60 is too much this.notifications = this.notifications.slice(0, maxNotificationsNumber);
if(this.platform.is('cordova')){ this.localNotifications.cancelAll().then(() => { this.localNotifications.schedule(this.notifications); this.notifications = []; }); } `
Context
What were you trying to do?
Debug logs
Include iOS / Android logs