我创建了两个证书,门户中的应用程序为开发和生产启用了APNS。
在开发过程中,它可以正常工作,但是在生产过程中,当有人下载应用程序并在我的服务器上签名时,NAPN就会更新,它代表的是没有推送通知。
这是如果用户禁用了它们的代码部分,但是我已经与多个用户进行了检查,它们完全启用了,但出于某种原因,这就像它被开发app证书之类的东西卡住了一样,用户在第一次下载并启动应用程序时也不会被提示启用推送通知。
我不知道我是否需要用这个问题来接近苹果,但是如果有人可以的话,请给出一些建议,建议如何让它发挥作用,这将是非常感谢的。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
//Clear notifications upon launching
[[UIApplication sharedApplication] cancelAllLocalNotifications];
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
//Register with APN
if ([[UIApplication sharedApplication] enabledRemoteNotificationTypes] != 0)
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}else
{
URLSingleton *registrar = [URLSingleton sharedInstance];
[registrar setDevToken:@"NAPN"];
//Register APN with iShame Service
URLSingleton *urls = [URLSingleton sharedInstance];
NSString *authString = [NSString stringWithFormat:@"{\"user\":\"%@\",\"token\":\"%@\"}", [[NSUserDefaults standardUserDefaults] valueForKey:@"session_token"], [registrar getDevToken]];
NSData *authData = [authString dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSMutableURLRequest *url = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urls.updateAuth]];
[url setHTTPMethod:@"POST"];
[url setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[url setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[url setValue:@"json" forHTTPHeaderField:@"Data-Type"];
[url setValue:[NSString stringWithFormat:@"%d", [authData length]] forHTTPHeaderField:@"Content-Length"];
[url setHTTPBody:authData];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:url delegate:self];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[connection start];
}
return YES;
}发布于 2013-04-25 10:16:36
您应该始终注册远程通知类型,因为该调用是导致用户在第一次启动应用程序时启用推送通知的原因。去掉那个条件。我不知道这段代码是如何在沙箱env中工作的。我的猜测是,在没有条件的情况下运行应用程序之后,您在稍后阶段添加了这个条件,这就是注册在env中的工作方式。
发布于 2013-04-25 03:41:46
当您创建.ipa时,而不是使用发行版构建(除非您将它放在商店中),使用开发人员许可证构建,这样应用程序将用您的签名对其进行签名。我对应用程序有问题,这就是我的问题。希望这能有所帮助!
https://stackoverflow.com/questions/16205955
复制相似问题