小编Ans*_*eed的帖子

通过单击应用程序图标直接启动应用程序时,无法获取通知数据

我有一个场景,其中应用程序将获得推送通知,并需要在我的应用程序的主屏幕中显示消息,因为我将消息数组保存到我的应用程序委托的用户默认值,一切正常,但在以下条件下它不起作用

  1. 如果应用程序处于被杀死状态并且发出通知并且用户通过应用程序图标触发应用程序(而不是来自推送通知)

  2. 如果应用程序在后台并且通知来了,用户也通过应用程序图标(不是来自推送消息)进入应用程序

然后我搜索了解决方案,并了解了静音推送通知(用于后台模式),没有别的,所以我需要知道如何通过推送通知处理所有场景,我的appdelegete是

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

NSDictionary *remoteNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];


    if (remoteNotif) {

        [self handlePushMessage:remoteNotif];
    }
    return YES;
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{

    [self handlePushMessage:userInfo];

}

-(void)handlePushMessage :(NSDictionary*)userInfo{

   //method to handle push message
}
Run Code Online (Sandbox Code Playgroud)

提前致谢

objective-c apple-push-notifications ios appdelegate

9
推荐指数
1
解决办法
1619
查看次数

Afnetworking 3.0迁移:如何使用xml post body发布

我试图将一些数据发布到服务器,主体格式为XML,一切正常

request.HTTPBody = [self.body dataUsingEncoding:NSUTF8StringEncoding];
request.HTTPMethod = @"POST";
 [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
Run Code Online (Sandbox Code Playgroud)

现在在Afnetworking 3.0中,他们将AFHTTPRequestOperation更改为AFHTTPSessionManager以任何方式使用AFHTTPSessionManager发布xml数据

ios afnetworking afnetworking-3

2
推荐指数
1
解决办法
3121
查看次数