Regardless of the language and library you are using, the push message payload is the JSON payload:
{ "aps": { "badge": 10, "alert": "Hello world!", "sound": "cat.caf" } }
aps current is Apple APN data. You can also add your data to your payload:
{ "aps": { "badge": 10, "alert": "Hello world!", "sound": "cat.caf" }, "job_id": 1 }
When you receive a notification in the application, check your setting in the notification dictionary:
- (void)handleBackgroundNotification:(NSDictionary *)notification { NSDictionary *aps = (NSDictionary *)[notification objectForKey:@"aps"]; NSMutableString *alert = [NSMutableString stringWithString:@""]; if ([aps objectForKey:@"alert"]) { [alert appendString:(NSString *)[aps objectForKey:@"alert"]]; } if ([notification objectForKey:@"job_id"]) {
Keep in mind that the total payload size is 256 bytes, and this of course includes your user parameters. Thus, you may need to (in order to reduce readability) call your own parameter "ji" instead of "job_id" to compress the bytes.
All of this is described in the Local and Push Notification Programming Guide in the iOS documentation. Definitely recommend reading because it is more complex than it originally sounds (at least what I thought).
typeoneerror Nov 15 2018-11-11T00: 00Z
source share