更新iOS 7.1后推送通知无效

时间:2014-06-18 05:40:29

标签: objective-c ios7

我的推送通知在iOS 7.1更新版本之前正常工作。它正在调用下面的app-delegate方法

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  NSString *strToken=[deviceToken description];
  strToken=[strToken stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
  strToken=[strToken stringByReplacingOccurrencesOfString:@" " withString:@""];
  strGlobalDeviceToken=strToken;
}

但是下面的AppDelegate方法没有调用..

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

  if([UIApplication sharedApplication].applicationState==UIApplicationStateActive )
  {
     UIAlertView *alertv=[[UIAlertView alloc]initWithTitle:nil message:[[userInfo objectForKey:@"aps"] objectForKey:@"alert"] delegate:self  cancelButtonTitle:@"Cancel" otherButtonTitles:@"View", nil];
    [alertv show];
  }
  else
  {
    [self remoteNotification];
  }

}

-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
   NSLog(@"Failed to get token, error: %@", error);
}

我没有得到我的代码有什么问题..我谷歌这个,我根据答案做了更改,但仍然无法正常工作。请帮我解决这个问题。在Android手机上我们得到推送通知,但它是不要只在iOS上调用..

1 个答案:

答案 0 :(得分:0)

您是否检查过您的APNS证书是否已过期?我最近也遇到了这个问题,更新证书会有所帮助。