Question

How can I go to a certain view when the app is opened from push notification? I am using storyboards. I have some views that push and some that are modal. I need to go to a certain view from anywhere in the app. This view is pushed by a view that is normally only access from a settings type page that pushes this view.

Was it helpful?

Solution

If your app is running in background.In that case.

When app is opened from push notification below method call.

-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

Using userInfo you can set your way which view to push. Suppose I wan't to go firstView that is depend on pushNotification In that condition I will add a value in APNS payload like view:firstView(that may be your class name) and using this value from userinfo(NSDictionary) you can navigate or push to particular view. In that condition your APNS payload will be like this

{"aps":{"alert":"Your message","sound":"value","badge":1},"ViewName":"value"}

OTHER TIPS

You can add extra parameters into Notification Payload. In the Push Notification Programming Guide section The Notification Payload it states

Providers can specify custom payload values outside the Apple-reserved aps namespace. Custom values must use the JSON structured and primitive types: dictionary (object), array, string, number, and Boolean. You should not include customer information as custom payload data. Instead, use it for such purposes as setting context (for the user interface) or internal metrics. For example, a custom payload value might be a conversation identifier for use by an instant-message client application or a timestamp identifying when the provider sent the notification. Any action associated with an alert message should not be destructive—for example, deleting data on the device.`

You can read this parameters in AppDelegate function application:willFinishLaunchingWithOptions:

There you can re-create UINavigationController instance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top