Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handle Push Notifications

I've a simple News application consisted of a UINavigationController , UITableViewController and UIViewController , When the app launches it loads the news from the web and then when click on the table cell it goes to the other view to show the full article , I 've added push notifications But I want to handle it now so when the user clicks on the notification the View with the article appears and if the user clicked the back button it goes to the News List Table , Can Anyone help with this ?

like image 798
Mohamed Elzarei Avatar asked Nov 04 '22 17:11

Mohamed Elzarei


1 Answers

in application:didFinishLaunchingWithOptions: you should take a look at what's in the launchOptions dictionary. Something like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    …
    NSDictionary *userInfo = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
    if ( userInfo != nil )
        [self handlePushNotification: userInfo];

    …
}

Don't forget to implement:

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

in case the push notification comes while your app is running.

In your handlePushNotification: method, you should create your view stack manually, likely with animated: NO.

like image 87
deepseadiving Avatar answered Nov 14 '22 01:11

deepseadiving