我对推送通知有一些问题。我可以将它们很好地发送到我的注册设备。一切正常。
我的问题是:单击查看按钮后,应用程序将启动。目前没有任何内容。
如何在此处添加内容?此内容应取决于我发出的推送通知。
例如:我的推送通知是关于第1号新闻的-单击查看后,我应该会获得有关第1号新闻的更多信息
以此类推。
此外,它应该可以阅读所有以前收到的新闻在一个列表中的应用程序,当从新闻编号1返回。
你明白我的意思吗?
我没有任何真正的idea...Would是很好,如果你可以告诉我关于一个例子的代码。
谢谢。
发布于 2012-06-15 16:52:28
只需实现以下代码,您就可以开始工作了:
// will be called if the app was not active
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self applicationDidFinishLaunching:application];
if (launchOptions != nil)
{
NSDictionary* dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (dictionary != nil)
{
// get the necessary information out of the dictionary
// (the data you sent with your push message)
// and load your data
}
}
return YES;
}
// will be called when in foreground
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// get the necessary information out of the dictionary
// (the data you sent with your push message)
// and load your data
}你可以在这里找到一个关于APNS的著名教程:http://www.raywenderlich.com/3525/apple-push-notification-services-tutorial-part-2
发布于 2012-06-15 16:52:16
如果您的应用程序在用户点击查看按钮时不在后台,则会调用application:didFinishLaunchingWithOptions:。该方法的第二个参数中的字典包含有关启动原因的信息(直接、来自推送或本地通知等)。以及通知的内容。
如果你的应用已经在后台,application:didReceiveRemoteNotification:会在它被唤醒时被调用。同样,第二个参数是一个包含通知内容的字典。
发布于 2013-01-30 22:45:55
生成通知的UUID时出错。您必须使用__bridge_transfer或CFBridgingRelease,而不是使用__bridge;否则CFStringRef将永远不会发布。
https://stackoverflow.com/questions/11047153
复制相似问题