繁体   English   中英

为什么我的发布应用程序无法接收apns的推送通知,但可以在开发人员版本上使用?

[英]Why my publish app can't receive the push notification of apns,it works on the developer version?

我发现发布的应用程序无法接收设备令牌,也无法在服务器中找到设备令牌,但是开发版本可以做到这一点。

这是我的注册码:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
 (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound |      UIRemoteNotificationTypeAlert)];

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken

{

NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentDir=[paths objectAtIndex:0];

NSFileManager *myFM=[NSFileManager defaultManager];

NSString *filepath = [documentDir stringByAppendingPathComponent:@"devicetoken.plist"];

if([myFM fileExistsAtPath:filepath]==NO){

NSString * str = [NSString stringWithFormat:@"%@",deviceToken];
dic = [[NSMutableDictionary alloc]init];

[dic setObject:[NSString stringWithString:@"DeviceToken"] forKey:@"type"];

[dic setObject:[NSString stringWithString:@""] forKey:@"_id"];

[dic setObject:str forKey:@"token"];

CJSONDeserializer * jo=[[CJSONDataSerializer alloc]autorelease];

NSData *data=[jo serializeDictionary:dic];

NSURL* url=[NSURL URLWithString:[NSString stringWithString:url]];

NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];

[request setHTTPMethod:@"POST"];

NSString *contentType = [NSString stringWithFormat:@"application/json"];

[request addValue:contentType forHTTPHeaderField: @"Content-Type"];

[request setHTTPBody:data];

putDoc = [NSURLConnection connectionWithRequest:request delegate:self];
}

切记:必须在Apple开发人员门户(在供应/应用程序下)中创建推送证书,然后才能构建和签名应用程序。

因此,我建议:->检查供应门户->应用程序,是否正确创建了生产推送证书->重新构建应用程序商店供应文件->使用重新构建证明重新构建应用程序。 文件

->再次将更新上传到应用商店

乔纳斯

您是否仍在使用推送通知开发配置文件? 如果不是,请将其更改为生产资料。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM