iOS push notification message - action after clicking VIEW button
apple-push-notifications, ios, php, push, push-notification
Solution
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
Problem
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.