How can I open my app, when user receive notification and my app was in background? Of course tap on notification itself would open app, but how to handle it with custom notification action?
I have implemented UNUserNotificationCenterDelegate and userNotificationCenter(_, didReceive, ...) already
Just need a code which would open my app and do specific action (for example go to specific view)
It would be nice if notification handler recognise that notification and open iPhone app or Apple Watch app depends on where action was tapped..
1 Turn on your iPhone or iPad in iOS 10. 2 From the Home screen, open the Settings app. 3 Select on General. 4 Select on Background App Refresh. 5 From the list of apps, change the toggle to OFF for the apps that you don’t want to refresh in the background.
The process for creating a notification has changed slightly in iOS 10. Developers must now create requests, which are requests to iOS to present a notification. These requests consist of 2 components: triggers and content. A trigger is a set of conditions that must be met for a notification to deliver.
The best you can do this is by using the feature called Background App Refresh on the iPhone and iPad in iOS 10. This feature allows you to control which apps have access to your mobile data and update in the background when you’re not using the app on your iPhone or iPad in iOS 10.
From the list of apps, change the toggle to OFF for the apps that you don’t want to refresh in the background.
A Swift 3/4 example (because I did not know how to set this option): important are the UNNotificationActionOptions
of the UNNotificationAction
.
let myAction = UNNotificationAction(identifier: "myActionIdentifier", title: "MyAction", options: [.foreground])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With