logo
In-app Chat
SDK Error Codes
Powered Byspreading
On this page

Get the payload field

Introduction

The offline push sender sends additional information to the receiver by configuring the payload parameter of ZIMPushConfig (the version before 2.5.0 is the extendedData parameter). When the receiver needs to use the ZPNs SDK, the payload in the extras of the push channel field to get this information.

This document introduces how to use the ZPNs SDK interface to obtain the payload transparent transmission field.

Warning

The ZPNs SDK must be used with ZIM SDK 2.0.0 or later.

Prerequisites

Implementation steps

  1. Implement the following methods in the ZPNsNotificationCenterDelegate protocol:
Untitled
// This method is triggered when the app receives an offline push when it is in the foreground
-(void)ZPNsNotificationCenter:(UNUserNotificationCenter *)center
      willPresentNotification:(UNNotification *)notification
                     userInfo:(NSDictionary *)userInfo
        withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(ios(10.0)){
    [userInfo objectForKey:@"payload"];
}

// This method is triggered when the user clicks the offline push notification
-(void)ZPNsNotificationCenter:(UNUserNotificationCenter *)center
    didReceiveNotificationResponse:(UNNotificationResponse *)response
                     userInfo:(NSDictionary *)userInfo
             withCompletionHandler:(void(^)(void))completionHandler API_AVAILABLE(ios(10.0)){
    [userInfo objectForKey:@"payload"];
}
1
Copied!
  1. Pass the object that implements the protocol into ZPNs through the setZPNsNotificationCenterDelegate method, get additional information from the "payload" field extracted by the above method, and then implement your business logic.
Untitled
[[ZPNs shared] setZPNsNotificationCenterDelegate:(id)yourObject];
1
Copied!

Previous

ResourcesID introduction

Next

Cross application offline push