开发者

Are push notifications stored somewhere on iphone?

开发者_JS百科

If yes, how it's possible for the user to re-read them again ? By coding, how do you read them to display them in your app ?


I'm pretty sure that the question was more about the notifications/banner messages which show up in the lock screen and all disappear when you unlock the phone, whether you actually read them or not. The phone just assumes you got them, and there is no way to retrieve them. It's one of the more poorly thought out aspects of the iPhone....up there with sorting contacts by last name if you enter one.


Push notification is not stored into application memory. But you can handle them as you want. There are mainly two case in which we need to handle the push notification:

1) Application is closed/background mode 2) Application is active mode

1) To Handle push when app is not running or in background, you need to click on push notification pop and it will open the application. Below is the code to handle this case:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
        self.isNoti = TRUE;
        NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithDictionary:[launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]];
// Do you stuff
    }
    return YES;
}

2) If your application is in active state:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
{
    @try {
        NSLog(@"Push Notification!!!");
}


Please, read Apple's documentation regarding push and local notifications to understand what's the difference and how they are different. Also, check this tutorial which will guide you on developing a sample app. that supports push notifications.

I hope you find them useful


You can see saved banner notifications by swiping the screen from top to bottom if using IOS 5 on your iPhone. Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜