roiberg
roiberg

Reputation: 13737

iPhone push notifications information

Is it possible to transfer any information in the push notification beside "badge" "sound" and "text"?

For example, in the app "whatsapp" when a push notification appears and pressed, the app is opened but not going to the conversation. My guess is that it can't know what conversation to go to. But then I saw that in facebook messenger app it actually goes in the conversation. how does the messenger app know that what conversation to go to?

Also, if it is possible to transfer information, why is it that apps like whatsapp don't use it and also ask you for your name so it will be displayed in the push?

Upvotes: 4

Views: 895

Answers (6)

Miguel Isla
Miguel Isla

Reputation: 1460

There are apps that have permission to run in the background and other apps that have not. May be facebook messenger app have this permission and can receive push notifications and do whatever is needed to go to the correct conversation or user. I don't know if this is true but it could be a possible reason.

Upvotes: 3

ganesh manoj
ganesh manoj

Reputation: 977

in this method we can display pushnotifications alerts and their action according to our app

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo   
{


    NSLog(@"did receive remore notification %@",userInfo);
    if(isForground)
    {
    }
}

Upvotes: 2

AppleDelegate
AppleDelegate

Reputation: 4249

Make sure the message size doesnt exceed 256 bytes.It is the threshold limit for the payload

Upvotes: 1

gasapladev
gasapladev

Reputation: 697

You can add more arguments in your payload. In our app we add something like groupID, or type. See this stack overflow for adding more payload arguments

APNS JSON PAYLOAD - more arguments

Upvotes: 1

Ahmed Al Hafoudh
Ahmed Al Hafoudh

Reputation: 8429

You should take a look at this documentation section Examples of JSON Payloads

At the bottom you can see custom payload examples like:

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

Where acme1 and acme2 are custom data that you can pass to the push notification and get it inside you app after launched.

The data is available through UIApplicationDelegate callbacks as described here Handling Local and Remote Notifications

Upvotes: 1

Cyupa
Cyupa

Reputation: 1135

Yes, indeed. But your message size (in bytes) must not pass a certain threshold Apple has imposed. You can then pull that info in the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions using something like this:

NSDictionary* dictionary = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];

Where dictionary contains your push notification info.

Upvotes: 3

Related Questions