PushNotifications的iOS 7,当用户点击图标不工作 [英] PushNotifications iOS 7 not working when user taps on icon

查看:143
本文介绍了PushNotifications的iOS 7,当用户点击图标不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的方法来处理推送通知。应用程序运行时,他们的工作完美的,我确实收到通知,当应用程序在后台。当用户敲击但它打开应用程序的图标,但我的看法UICollection不重新加载方式,当用户收到应用程序运行时通知它。

   - (无效)应用:(*的UIApplication)的应用didReceiveRemoteNotification:(NSDictionary的*)USERINFO
{
    UIApplicationState状态= [应用applicationState]
    如果(状态== UIApplicationStateActive){
        //做的东西,当应用程序被激活
        * NSString的cancelTitle = @关闭;
        * NSString的showTitle = @确定;
        * NSString的消息= [[USERINFO valueForKey:@APS] valueForKey:@警报];
        * NSString的类型= [USERINFO objectForKey:@型];        UIAlertView中* alertView = [[UIAlertView中页头] initWithTitle:@Linkedstar
                                                            消息:消息
                                                           委托:自我
                                                  cancelButtonTitle:cancelTitle
                                                  otherButtonTitles:showTitle,无]        如果([类型isEqualToString:@消息]){
            alertView.tag = alertMessage;
        }
        否则,如果([类型isEqualToString:@后]){
            alertView.tag =岗位;
        }
        否则,如果([类型isEqualToString:@接触]){
            alertView.tag =接触;
        }        [alertView秀]        [自presentViewForPush:用户信息的updateUI:YES];
    }
    其他
    {
        //做的东西,当应用程序在后台
        的NSLog(@接到通知:%@,用户信息);
        [个体经营handlePush:用户信息的updateUI:YES];
    }
} - (BOOL)应用:(*的UIApplication)的应用didFinishLaunchingWithOptions:(NSDictionary的*)launchOptions
{
    *的NSDictionary = pushDict [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    如果(pushDict)
    {
        [个体经营handlePush:pushDict的updateUI:YES];
    }
}

我需要帮助搞清楚如何当用户在icon.I水龙头已经尝试了几种不同的选择在网上做一些研究和非工作后,办理launchOptions数据。
任何帮助是极大的AP preciated。谢谢你。


解决方案

你读过这<一个href=\"https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html\"相对=nofollow>调度,注册,和处理


  

如果操作按钮被窃听(运行iOS的设备上),系统
  启动应用程序和应用程序调用其委托的
  应用:didFinishLaunchingWithOptions:方法中(如果实现的话);它
  通过在通知有效载荷(用于远程通知)或
  本地通知对象(本地通知)。


  
  

如果在应用程序图标被窃听运行iOS的设备上
  应用程序调用相同的方法,但配料的没有信息关于
  通知


I have the methods below to handle push notifications. They work perfect when the app is running and I do receive notifications when the app is in the background. When a user taps the icon however it opens the app but my UICollection view is not reloaded the way it is when a user receives the notification when the app is running.

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    UIApplicationState state = [application applicationState];
    if (state == UIApplicationStateActive) {
        // do stuff when app is active
        NSString *cancelTitle = @"Close";
        NSString *showTitle = @"Ok";
        NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
        NSString *type = [userInfo objectForKey:@"type"];

        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Linkedstar"
                                                            message:message
                                                           delegate:self
                                                  cancelButtonTitle:cancelTitle
                                                  otherButtonTitles:showTitle, nil];

        if([type isEqualToString:@"message"]) {
            alertView.tag = alertMessage;
        }
        else if([type isEqualToString:@"post"]) {
            alertView.tag = post;
        }
        else if([type isEqualToString:@"contact"]) {
            alertView.tag = contact;
        }

        [alertView show];

        [self presentViewForPush:userInfo updateUI:YES];
    }
    else
    {
        // do stuff when app is in background
        NSLog(@"Received notification: %@", userInfo);
        [self handlePush:userInfo updateUI:YES];
    }
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSDictionary *pushDict = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if(pushDict)
    {
        [self handlePush:pushDict updateUI:YES];
    }
}

I need help figuring out how to handle the launchOptions data when the user taps on the icon.I have tried a couple of different options after doing some research online and non worked. any help is greatly appreciated. Thank you.

解决方案

Have you read this Scheduling, Registering, and Handling Notifications

If the action button is tapped (on a device running iOS), the system launches the application and the application calls its delegate’s application:didFinishLaunchingWithOptions: method (if implemented); it passes in the notification payload (for remote notifications) or the local-notification object (for local notifications).

If the application icon is tapped on a device running iOS, the application calls the same method, but furnishes no information about the notification

这篇关于PushNotifications的iOS 7,当用户点击图标不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆