Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS push notification message - action after clicking VIEW button

i have some problems with the Push Notifications. I can sent them well to my registered Devices. All works fine.

My Questions is: After clicking the VIEW button, the App is launching. At the moment without any content.

How can i add content here? This content should depend on the Push Notification i sent out.

For example: My Push Notification is about NEWS Number 1 - then after clicking VIEW i should get more informations about NEWS Number 1

and so on...

Also it should be possible to read all previous received NEWS in the App in a list, when getting back from NEWS Number 1.

You understand, what i mean?

I dont have any real idea...Would be nice if you can show me code regarding to an example.

Thanks.

like image 522
emitremmus Avatar asked Jun 15 '12 08:06

emitremmus


People also ask

How do you see notifications on iPhone After clicking on it?

Find your notifications in Notification Center To see your notifications in Notification Center, do any of the following: On the Lock Screen: Swipe up from the middle of the screen. On other screens: Swipe down from the top center. Then you can scroll up to see older notifications, if there are any.

Do push notifications work when app is closed iOS?

Apple does not offer a way to handle a notification that arrives when your app is closed (i.e. when the user has fully quit the application or the OS had decided to kill it while it is in the background). If this happens, the only way to handle the notification is to wait until it is opened by the user.

Can push notifications be intercepted?

Push notifications, when implemented properly, are resistant to interception or redirection and are, therefore, more secure than SMS.


1 Answers

Just implement the following code and you are good to go:

// will be called if the app was not active
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self applicationDidFinishLaunching:application];

    if (launchOptions != nil)
    {
        NSDictionary* dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
        if (dictionary != nil)
        {
            // get the necessary information out of the dictionary 
            // (the data you sent with your push message)
            // and load your data
        }
    }
    return YES;
}

// will be called when in foreground
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {    
    // get the necessary information out of the dictionary 
    // (the data you sent with your push message)
    // and load your data
  }

You can find a well-known tutorial on APNS here: http://www.raywenderlich.com/3525/apple-push-notification-services-tutorial-part-2

like image 96
tilo Avatar answered Sep 28 '22 03:09

tilo