iOS:如何注册推送通知? [英] iOS: how to register for push notifications?

查看:51
本文介绍了iOS:如何注册推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照 Ray Wenderlich 的指南为我的 iOS 5 应用程序实现推送通知:http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12.

I'm trying to implement Push Notifications for my iOS 5 application by the guide from Ray Wenderlich: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12.

我已将以下内容插入到我的 AppDelegate 的 didFinishLaunchingWithOptions 方法中:

I've inserted the following into my didFinishLaunchingWithOptions method in my AppDelegate:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
    (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

在我的设备(不是模拟器)上运行应用程序时,不会显示告诉我接受推送通知的弹出窗口/警报.我已经在线路上插入了一个调试点,我可以看到,registerForRemoteNotificationTypes 被调用.

When running the application on my device (not simulator) the popup/alert telling me to accept push notifications isn't displayed. I've inserted a debug-point on the line, and I can see, that the registerForRemoteNotificationTypes is called.

为什么什么都没发生?

推荐答案

也许,请删除您的应用并重试.该对话框只出现一次.但是我不确定当您重新安装该应用程序时该对话框是否会再次出现.

Maybe, delete your app and try again. That dialog only appears once. But I'm not sure that whether that dialog will appear again when you reinstall that app.

您也可以到您的设置应用通知中心,查看您的应用是否在列表中.

You can also go to your setting app the notification center, see if your app is on the list.

还可以添加断点,看看 didRegisterForRemoteNotificationsWithDeviceToken 是否执行.

You can also add a break point and see if didRegisterForRemoteNotificationsWithDeviceToken executes.

这篇关于iOS:如何注册推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆