0

I have an Alarm app which is pushing the local notifications to alert the user. I couldn't create a specific number of local notifications as they have to notify the user until he perform the actions(1. Tap on notification and opens the app, 2. By tapping the app icon and opening the app). As the app only allows 64 notifications to be scheduled, I couldn't create more than that.

I have got a logic that the local notifications are getting cleared one by one after received a specific number of notifications and the upcoming is receiving to the user (So it will keep 20 always until he opens the app in the notification status bar). This will help to play local notifications for infinite number of times until the user responds to the Local Notification.

But am stuck with clearing Local Notifications when the app is terminated. (When the app is in foreground we can clear each local notifications with its unique Identifier, and this has been worked out).

Above scenario is working fine in Alarmy App in Appstore(Reference)

1 Answers1

0

You can configure your logic in didFinishLaunchingWithOptions in AppDelegate.

       if let launchOptions = launchOptions {
            if let userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] {
                 // change condition and add logic here 
                if let action = userInfo["action"], id = userInfo["id"] {

                    })
                 }
            }
        }
KKRocks
  • 8,222
  • 1
  • 18
  • 84
  • Am intending to clear the Local Notifications without a user Interaction. Neither tapping Local Notification and Opening the App. In short i can say "How to schedule to Delete a Local Notification for a particular time?" – Jithesh Xavier Apr 25 '17 at 05:34
  • yes you can do also this when you open app if any notification arrived then you can track here . – KKRocks Apr 25 '17 at 05:36
  • Yes I know that the Notifications can be cleared like the answer you said above. But how to clear without do any of those actions? – Jithesh Xavier Apr 25 '17 at 05:37
  • once you open app ....your notification values stored in didFinishLaunchingWithOptions's NSDictionary object. – KKRocks Apr 25 '17 at 05:40
  • The user not gonna open app for a 5 - 10 minutes duration and the Notification should alert in each 5 seconds gap until 10 minutes. But here we have the limitation to schedule only 64 Nos. What we can do to schedule 100 or more? – Jithesh Xavier Apr 25 '17 at 05:47
  • For a better understanding of the said scenario, could you please refer the Alarmy App in Appstore. And do check scheduling an alarm and kill the App. Local Notifications will arrive more than 64 nos. And it will continue to receive until the user opens the app and Dismiss the Alarm. – Jithesh Xavier Apr 25 '17 at 05:50
  • If you enabled the remote notifications background mode, the system launches your app (or wakes it from the suspended state) and puts it in the background state when a remote notification arrives. However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again. - https://developer.apple.com/reference/uikit/uiapplicationdelegate/1623013-application – KKRocks Apr 25 '17 at 05:59
  • I was referring to the Local Notification and pls let me know suppose if we want to show alert 100 notifications and successfully the Notification centre will schedule those 100 but it will fire only first 64 nos. And the 65th local notification will fire only when we clear/delete 1 notification from the delivered list. How we can achieve this when the app is terminated. This is what i need to do. – Jithesh Xavier Apr 25 '17 at 06:41
  • i understood but there is not way if user terminate app forcefully . – KKRocks Apr 25 '17 at 06:42
  • Then how alarmy apps does it? Even after switch off and on the phone they starting throwing notifications one after another. – Amrit Trivedi Mar 31 '19 at 14:22