推送通知

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];
    }*/

    }
}

请尽快帮助我

2个回答

3

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


设备令牌?它会改变吗? - Rolf Koenders
是的。您应该在每次启动应用程序时获取令牌。苹果不告诉我们设备令牌何时更改。因此,我们在每次启动时都会获取一个新令牌。 - nurnachman

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.

关于推送通知的详细信息请参见:
开发者苹果-ApplePushService


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接