Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Regardless of the language and library you use, the push notification payload is a JSON payload:</p> <pre><code>{ "aps": { "badge": 10, "alert": "Hello world!", "sound": "cat.caf" } } </code></pre> <p>The <code>aps</code> token is the Apple APN data. You can add custom data to your payload as well:</p> <pre><code>{ "aps": { "badge": 10, "alert": "Hello world!", "sound": "cat.caf" }, "job_id": 1 } </code></pre> <p>When you receive the notification in the app, check for your param in the notification dictionary:</p> <pre><code>- (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"]) { // do something with job id int jobID = [[notification objectForKey:@"job_id"] intValue]; } } </code></pre> <p>Keep in mind that the total size of the payload is 256 <em>bytes</em>, and that includes, of course, your custom parameters. So you may have to (at risk of reducing readability) call your custom param "ji" instead of "job_id" to squeeze bytes.</p> <p>All of this is documented in the <a href="https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html" rel="nofollow noreferrer">Local and Push Notification Programming Guide</a> in the iOS documentation. Definitely would recommend a read because it's more complex than it initially sounds (at least, that's what I thought).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload