IPhone push info

Is it possible to transmit any information in a push notification next to "badge" "sound" and "text" ?

For example, in the "whatsapp" application "whatsapp" when a push notification appears and "whatsapp" application opens, but does not proceed to the conversation. I guess he cannot know what to go on. But then I saw that in the facebook messenger app this really goes into conversation. how does the messenger app know which conversation to go to?

In addition, if it is possible to transmit information, why applications such as whatsapp do not use it and also ask for your name so that it appears in push?

+4
source share
6 answers

Yes indeed. But your message size (in bytes) should not pass the specific threshold that Apple imposed. You can then extract this information in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions using something like this:

 NSDictionary* dictionary = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey]; 

If the dictionary contains information about your push notification.

+3
source

There are applications that have permission to run in the background and other applications that did not. Maybe the facebook messenger app has this permission and can receive push notifications and do whatever it takes to get to the right conversation or user. I do not know if this is true, but this may be a possible reason.

+3
source

in this method we can display pushnotifications warnings and their actions in accordance with our application

 -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { NSLog(@"did receive remore notification %@",userInfo); if(isForground) { } } 
+2
source

You should look at this section of the documentation. Examples of useful JSON data.

Below you can see examples of user payloads, for example:

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

Where acme1 and acme2 are user data that you can send in a push notification and receive it inside your application after launch.

Data is accessible through UIApplicationDelegate callbacks as described here Handling local and remote notifications

+1
source

You can add more arguments to your payload. In our application, we add something like groupID or type. See This Stack Overflow for Additional Payload Arguments

APNS JSON PAYLOAD - more arguments

+1
source

Make sure the message size does not exceed 256 . This is the payload threshold.

+1
source

Source: https://habr.com/ru/post/1441462/


All Articles