Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 10 UNNotificationAction Open App from Background

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..

like image 316
Adam Smaka Avatar asked Sep 19 '16 09:09

Adam Smaka


People also ask

How do I Turn Off background refresh on iOS 10?

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.

What is the new notification process in iOS 10?

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.

What is background app refresh on the iPhone and iPad?

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.

How do I stop apps from running in the background?

From the list of apps, change the toggle to OFF for the apps that you don’t want to refresh in the background.


1 Answers

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])
like image 157
palme Avatar answered Oct 04 '22 15:10

palme