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

发布于 2024-12-10 21:18:28 字数 1541 浏览 0 评论 0原文

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

这是我的注册码:

[[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];
}

I found that the publish app can't receive the device token.I can't find the device token in my server.But the develop version can do this.

This is my register code:

[[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];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千纸鹤带着心事 2024-12-17 21:18:28

记住:
Apple 开发者门户(在配置/应用程序下)中的推送证书必须在应用程序构建和签名之前创建。

所以我会推荐:
->检查配置门户 ->如果正确创建了生产推送证书,则应用程序
->重新构建应用程序商店配置文件
->使用 re-buil prov 重新构建应用程序。文件

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

Jonas

Remember:
The push certificate in the Apple Developer Portal (under provisioning / application) must be created before the app built and signed.

So i would recommend:
-> check in the provisioning portal -> application if the production push certificate is proper created
-> re-build the app store provisioning file
-> re-build the app with the re-buil prov. file

-> upload again a update to the app store

Jonas

幼儿园老大 2024-12-17 21:18:28

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

Do you still use the push notification development profile ?
If not, change it to the production profile.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文