推送测试,生产环境无法打印log获取deviceToken,可以通过弹窗获取deviceToken


z- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSString *token = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<" withString:@""] stringByReplacingOccurrencesOfString:@">" withString:@""] stringByReplacingOccurrencesOfString:@" " withString:@""]; NSLog(@"deviceToken:\n%@\n", token); UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"当前的token" message:token delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil]; [alertView show]; NSString *tokens = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]]; NSLog(@"deviceToken=%@", tokens); // [self testGetClientId]; }

想要在生产环境测试推送,但是生产环境看不到log信息,怎么办呢?写个弹窗,显示deviceToken,打包成ADhoc,上传蒲公英,下载安装后就能看到生产环境的deviceToken了。注意:生产环境的deviceToken跟开发环境不同。获取生产环境的deviceToken后就能在生产环境测试推送了

 

这玩意是设置了推送能力之后自动生成的

posted on 2019-04-25 11:40  土匪7  阅读(537)  评论(0编辑  收藏  举报