4

我使用的服务器链接http://stefan.hafeneger.name/download/PushMeBabySource.zip

我使用 PushMeBaby 服务器和推送应用程序以及我的证书和配置文件,它在设备上以警报的形式发出通知,并仅在我第一次运行应用程序时在控制台上打印以方法编写的语句,但在下一次多次运行应用程序时为了测试它只返回设备令牌,下面的方法根本不执行。请帮我解决这个问题。

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

    for (id key in userInfo) {
    NSLog(@”key: %@, value: %@”, key, [userInfo objectForKey:key]);

    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@”alert” message:key delegate:self cancelButtonTitle:@”ok” otherButtonTitles:nil];
    [alert show];

    /*if(key)
    {

    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@”alert” message:@”this is in application” delegate:self cancelButtonTitle:@”ok” otherButtonTitles:nil];
    [alert show];
    }*/

    }
}

请尽快帮助我

4

2 回答 2

3

每次启动应用程序时都需要获取令牌。有时它会改变。

于 2011-09-02T11:31:35.023 回答
2
The delegate (didReceiveRemoteNotification) gets invoked when a running application receives a remote notification.  

If you implement application:didFinishLaunchingWithOptions: to handle an incoming push notification that causes the launch of the application, this method (didReceiveRemoteNotification) is not invoked for that push notification.

有关推送通知的详细信息,请参阅:
开发者 apple-ApplePushService

于 2011-09-02T12:21:07.483 回答