开发者

Dismissing/Updating Local Notification Programmatically in iPhone sdk4

开发者 https://www.devze.com 2023-01-18 13:39 出处:网络
I am working on an app that runs in the background with the backgroundmode set to location. In the didUpdateToLocation: method, I want to generate local notification. I want the app to show the notifi

I am working on an app that runs in the background with the backgroundmode set to location. In the didUpdateToLocation: method, I want to generate local notification. I want the app to show the notification only when previous notification has been viewed. Another option is to show only the latest notification and dismiss all the 开发者_如何学Pythonprevious notifications programmatically (i.e. without user interaction). Please guide me how is it possible?


Try this:

        UIApplication *app = [UIApplication sharedApplication];
    NSArray *oldNotifications = [app scheduledLocalNotifications];

    // Clear out the old notification before scheduling a new one.
    if ([oldNotifications count] > 0) {
        [app cancelAllLocalNotifications];
    }
0

精彩评论

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

关注公众号