推送通知-查看按钮操作 [英] Push Notification - View Button action

查看:58
本文介绍了推送通知-查看按钮操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正常工作的App女巫发送了我的推送通知",没有任何问题.点击推送"的查看"按钮后-应用已打开,但看到的是空白屏幕,没有任何内容.

i have a working App witch sends without any problems my Push Notifications. After clicking the "View" Button of the Push - the App is open, but a blank screen is seen, without any content.

我如何使它工作,单击查看按钮后,我将在应用程序中看到内容"?

How will i get it to work, that after clicking the View Button i will see "Content" in the App?

我的想法是(例如):我收到具有以下内容的推送通知:今天您在我们的商店中获得30%的折扣

My idea is (for example): I receive a Push Notification with the following Content: Today you get a Discount of 30% in our Shop

单击查看"后,我将进入应用程序,并可以阅读包含所有内容的完整消息.我的意思是像博客一样工作.推送通知是前一篇文章,查看"按钮是阅读更多"标签.在我的应用程序中,我可以阅读几篇文章.就像这里一样: http://www.myfitapp.de/fitnessstudio-app/push-nachrichten/

After clicking View i will get into the App and can read the full Message with all content. I mean working like a Blog. The Push Notification is the Pre-Article and the "View" Button the "Read More" Tag. And in my App i have several Articles witch i can read. Just like here: http://www.myfitapp.de/fitnessstudio-app/push-nachrichten/

有可能吗?以及如何?

推荐答案

是的,当然可以.但是您不能通过推送通知发送大量内容.v推送通知总共最多可以为256个字节.

Yes, of course this is possible. But you can't send the a lot of content with the push notification.v The push notification can be a maximum of 256 bytes in total.

您可以做的是将一些数据添加到通知的userInfo中,链接一个ID.然后,在用户打开后,您的应用会通过解析通知中的ID从服务器获取内容.

What you can do is add some data to the userInfo of the notification, link an ID. Then after te user opens you app fetch the content from a server by parsing out the ID in the notification.

如果用户单击通知时您的应用未运行

If your app isn't running when the user clicks on the notification

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


   NSDictionary *remoteNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
   if (remoteNotif) {
      ///Handle the notification
   } 

   /* Your regular init  */

   return YES; 
}

如果您的应用程序正在运行,则此方法称为:

If your app is running this method is called:

- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
  ///Handle the notification
}

NSDictionary 中,您可以获得通知msg以及已添加到通知中的任何其他数据.

In the NSDictionary you can get the notification msg and any other data you have added to the notification.

-

推送通知的Userinfo部分只是JSON,

The Userinfo part of the push notification it is just JSON, The Notification Payload.

{
    "aps" : {
        "alert" : "You got your emails.",
        "badge" : 9,
        "sound" : "bingbong.aiff"
    },
    "acme1" : "bar",
    "acme2" : 42
}

这个例子来自苹果公司,JSON的 aps 部分告诉应用程序在徽章图标中显示9并显示您收到了电子邮件".作为消息文本.收到此通知后,系统会在应用程序捆绑包中查找 bingbong.aiff 声音,并在播放时播放该声音.

This example from Apple, the aps part of the JSON tells the app to show 9 in badge icon and "You got your emails." as the message text. On receiving this notification the system looks in the app bundle for the bingbong.aiff sound and if found plays it.

其他键 amce1 amce2 随通知一起发送,您可以从作为推送通知的字典中访问.

The other keys, amce1 and amce2 are send with the notification and you can acces the from the dictionary that is the push notification.

这篇关于推送通知-查看按钮操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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