iphone apns在应用程序通知警报显示重复

问题描述:

我已经研究和实施射线的这些令人敬畏的教程上apns http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 http://www.raywenderlich.com/3525/apple-push-notification-services-tutorial-part-2iphone apns在应用程序通知警报显示重复

他们r工作正常,即使在生产模式我实施他们,现在我想显示警报类型通知时,应用程序是在前台(运行)而不是气泡,所以我做了什么,我使用nsnotification,我张贴内部通知 addMessageFromRemoteNotification:(NSDictionary *)userInfo updateUI:(BOOL)像这样的updateUI方法

NSMutableArray* parts = [NSMutableArray arrayWithArray:[alertValue componentsSeparatedByString:@": "]]; 
     message.senderName = [parts objectAtIndex:0]; 
     [parts removeObjectAtIndex:0]; 
     message.text = [parts componentsJoinedByString:@": "]; 
     int index = [dataModel addMessage:message]; 
     [MySingleton sharedMySingleton].Msender = message.senderName; 
     [MySingleton sharedMySingleton].Mtext = message.text; 

     [[NSNotificationCenter defaultCenter] postNotificationName:@"Notificationreceived" object:nil]; 

,然后我加入观察者在登录视图CONTROLER这样

- (void)viewWillAppear:(BOOL)animated 
{ 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(responseFromServer) name:@"TokenRecieved" object:nil]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(displaynotif) name:@"Notificationreceived" object:nil]; 
    [super viewWillAppear:animated]; 
} 

-(void)displaynotif 
{ 
    NSString *msgsender = [MySingleton sharedMySingleton].Msender; 
    NSString *msgtext = [MySingleton sharedMySingleton].Mtext; 
    NSString *Compmsg = [NSString stringWithFormat:@"%@ %@", msgsender, msgtext]; 
    UIAlertView * view=[[UIAlertView alloc] initWithTitle:@"Alert" message:Compmsg delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil]; 
      [view show]; 
      [view release]; 
} 

现在我有一个问题,即当第一通知来只显示一次,但是当第二配它显示两次(相同的通知)和第三次来了三次等,我使用这个PHP脚本的服务器端和通知正在从服务器端通过一个PHP的Web形式发送

https://github.com/sebastianborggrewe/PHP-Apple-Push-Notification-Server 我也删除dealloc中的观察者。 我不知道最新情况,PLZ。引导感谢名单

+0

PLZ 。指导我,因为我很长一段时间卡在这里了。 – 2012-03-05 09:27:07

你必须调试深入到框架,做实际的连接,看看服务器的响应或至少SSL连接的例外是,但我的猜测是,你有过期的证书 - 他们不会持续更