0

I am from Android background, now working in cross platform mobile application. I don't have any knowledge in iOS. In my application, I need to customize the push notification in displayed in the notification bar. In Android I achieve this. Can any one help me in iOS?

This is my json data :

{
"Test1":"Value 1",
"Test2":"Problem:[{"a":"b"},{"c":"d"}]"
}

Output should be : Value 1 --> b ,d

What I have tried

- (void)handleBackgroundNotification:(NSDictionary *)notification
{
     NSMutableString *alert = [NSMutableString stringWithString:@""];
    if ([notification objectForKey:@"Test1"]){
        [alert appendString:(NSString *)[notification objectForKey:@"Test1"]];
    }
}

I dont know if this is correct.

4

1 回答 1

2

You are sending Apple Push Notifications from your server to an iOS application. Apple Push Notifications offer much less freedom than Android's GCM. The JSON you are sending should look like this :

{"aps":{"alert":"message","badge":3,"sound":"sound-file-name"},"custom-property":"custom-value"}

The only parameter used to display the notification is the "alert" parameter (there are some minor variations - the "alert" parameter can be a dictionary by itself and define some additional parameters used for displaying the message, but none of them is a custom parameter).

You can add custom parameters, as shown above, but they will not be shown in the notification (they will be passed to the method that handles the notification if the user taps on the notification). Unlike Android, you don't write the code that displays the notification. In iOS it's part of the operating system.

You can further read about the notification payload here.

于 2014-06-25T14:37:21.913 回答