Protocol
2026-07-06
| ZPNsManager | ZPNsNotificationCenterDelegate |
ZPNsManager
详情
ZPNsManager SDK 主类。
Declared in ZPNs.h
方法
getVersion
static
getVersion
+ (NSString *)getVersion;获取 SDK 版本号。
Declared in
ZPNs.h在 SDK 在运行过程中若遇到异常,可将问题、日志等信息提交 ZEGO 技术人员定位与排障。开发者也可通过该 API 收集当前 SDK 版本信息,便于 App 运营统计以及关联问题。
- 调用时机:任意时刻。
- 支持版本:1.0.0 及以上。
- 使用限制:无。
- 注意事项:无。
SDK 版本号。
setPushConfig
static
setPushConfig
+ (void)setPushConfig:(ZPNsConfig) config;设置各家厂商的推送设置项。
Declared in
ZPNs.h参数
| 名称 | 类型 | 描述 |
|---|---|---|
| config | ZPNsConfig | 推送设置 |
详情
设置各家厂商的推送设置项。
- 支持版本:2.0.0 及以上。
- 使用限制:开发者需要使用该方法来设置厂商推送的配置。
- 注意事项:需要设置厂商推送时调用。
shared
static
shared
+ (ZPNs *)getInstance;获得 ZPNs 实例。
Declared in
ZPNs.h使用 ZPNs SDK 时,开发者应直接调用该 API 获取内部单例对象,而无需自行创建并且维护对象。
- 调用时机:任意时刻。
- 支持版本:2.0.0 及以上。
- 使用限制:无。
- 注意事项:使用 ZPNs 时需要通过此方法获取 ZPNs 单例对象。
SDK 单例对象,用于后续的 API 调用。
setZPNsNotificationCenterDelegate:
setZPNsNotificationCenterDelegate:
- (void)on<K extends keyof ZPNsEventHandler>:() delegate;设置 ZPNs 推送事件通知回调。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| delegate | 实现了 ZPNs 回调协议的回调对象。 |
详情
设置事件通知回调,用于监听 ZPNs 注册成功事件、推送点击等回调。
- 支持版本:2.0.0 及以上。
- 使用限制:无。
setDeviceToken
setDeviceToken
- (void)setDeviceToken:(NSData *) deviceToken :(BOOL) isProduct;使用该方法将 deviceToken 传入 ZPNs 并得到 PushID。
Declared in
ZPNs.h参数
| 名称 | 类型 | 描述 |
|---|---|---|
| deviceToken | NSData * | |
| isProduct | BOOL |
详情
使用该方法将 deviceToken 传入 ZPNs 并得到 PushID。
- 业务场景:该方法应在 iOS 官方接口 didRegisterForRemoteNotificationsWithDeviceToken 触发后使用,并在此接口中将deviceToken 参数传入。
- 调用时机/通知时机:iOS 官方接口 didRegisterForRemoteNotificationsWithDeviceToken 触发后使用。
- 支持版本:2.0.0 及以上版本。
- 注意事项:该方法的 isProduct 布尔值,在处于开发环境时填 false,处于生产环境是填 true。
setVoipToken
setVoipToken
- (void)setVoipToken:(NSData *) deviceToken :(BOOL) isProduct;Declared in
ZPNs.h参数
| 名称 | 类型 | 描述 |
|---|---|---|
| deviceToken | NSData * | |
| isProduct | BOOL |
registerAPNs
registerAPNs
- (void)registerAPNs;该方法用于注册厂商离线推送。
Declared in
ZPNs.h该方法用于注册厂商离线推送,注册结果将会在 [onRegistered] 方法中获取。
- 支持版本:2.0.0 及以上版本。
- 注意事项:无。
unregisterAPNs
unregisterAPNs
- (void)unregisterAPNs;不需要离线推送时可调用此方法反注册。
Declared in
ZPNs.h不需要离线推送时可调用此方法反注册。
- 业务场景:当用户点击应用程序内的关闭消息通知时可调用该方法反注册。
- 调用时机/通知时机:需要反注册时调用。
- 支持版本:2.0.0 及以上版本。
- 使用限制:需要在 [registerPush] 调用后才可调用。
addLocalNotificationWithContent:trigger:withCompletionHandler:
addLocalNotificationWithContent:trigger:withCompletionHandler:
deprecated
- (void)addLocalNotificationWithContent:(UNMutableNotificationContent *) content trigger:(UNTimeIntervalNotificationTrigger *) trigger withCompletionHandler:(void (^)(NSError *__nullable error)) completionHandler;添加一条本地推送。
Declared in
ZPNs.h参数
| 名称 | 类型 | 描述 |
|---|---|---|
| content | UNMutableNotificationContent * | 可参考 Apple 官方文档UNMutableNotificationContent。 |
| trigger | UNTimeIntervalNotificationTrigger * | 可参考 Apple 官方文档 UNTimeIntervalNotificationTrigger。 |
| completionHandler | void (^)(NSError *__nullable error) |
- 详细描述:当开发者的 App 位于前台或刚推到后台且未被冻结时,后台未感知到该用户已掉线的情况下不会发送离线推送。这时若开发者需要补推送通知的情况下,可以使用该接口手动为设备发送一条本地推送消息。
已废弃
该接口废弃于 2.4.0,请使用另一个方法 [addLocalNotificationRequest] 代替。
addLocalNotificationRequest:withCompletionHandler:
addLocalNotificationRequest:withCompletionHandler:
- (void)addLocalNotificationRequest:(UNNotificationRequest *) request withCompletionHandler:(void (^)(NSError *__nullable error)) completionHandler;添加一条本地推送。
Declared in
ZPNs.h参数
| 名称 | 类型 | 描述 |
|---|---|---|
| request | UNNotificationRequest * | 可参考 Apple 官方文档UNNotificationRequest。 |
| completionHandler | void (^)(NSError *__nullable error) | 与结果一起执行的 block。可参考 Apple 官方文档。 |
- 详细描述:当开发者的 App 位于前台或刚推到后台且未被冻结时,后台未感知到该用户已掉线的情况下不会发送离线推送。这时若开发者需要补推送通知的情况下,可以使用该接口手动为设备发送一条本地推送消息。
setBadge:
setBadge:
- (void)setBadge:(int) badge;通过该接口向 ZPNs 服务器上报当前 App 的角标数。
Declared in
ZPNs.h参数
| 名称 | 类型 | 描述 |
|---|---|---|
| badge | int | 需要设置的值。 |
详情
通过该接口向 ZPNs 服务器上报当前 App 的角标数。当 App 离线后,ZPNs 将基于之前上报的角标数进行变更。
- 业务场景:当开发者本地角标发生变更时,调用该接口上报。
- 默认值:若接收端不上报当前角标数,则接收推送时,ZPNs 不会自动修改角标。
- 调用时机:任意时机可调用, 但实际向后台上报时机在 pushID 注册成功并且用户登录后,登出前。
- 支持版本:ZPNs 2.6.0 及以上版本。
- 使用限制:暂时没有单接口限频。目前仅 iOS 端需要设置本接口。uni-app SDK 暂不支持该接口。
- 注意事项:badge 不可小于 0。
ZPNsNotificationCenterDelegate
详情
Declared in ZPNs.h
方法
onRegistered
onRegistered
- (void)onRegistered:(NSString *) pushID;SDK 注册推送结果回调。
Declared in
ZPNs.h参数
| 名称 | 类型 | 描述 |
|---|---|---|
| pushID | NSString * | ZPNs 推送 ID。 |
详情
当注册离线推送服务时 SDK 生成 PushID 后触发的回调。
- 业务场景:开发者在接入 SDK 后,若需要获得 PushID 可实现此回调。
- 支持版本:2.0.0 及以上版本。
ZPNsNotificationCenter:didReceiveNotificationResponse:userInfo:withCompletionHandler:
ZPNsNotificationCenter:didReceiveNotificationResponse:userInfo:withCompletionHandler:
- (void)ZPNsNotificationCenter:didReceiveNotificationResponse:userInfo:withCompletionHandler:;SDK 离线推送点击通知事件。
Declared in
ZPNs.h当用户通过离线推送点击打开应用后,可以通过该回调获取到离线推送里的自定义内容。
- 业务场景:便于开发者在点击推送打开应用后获取自定义内容做业务页面跳转等操作。
- 支持版本:2.0.0 及以上版本。
ZPNsNotificationCenter:willPresentNotification:userInfo:withCompletionHandler:
ZPNsNotificationCenter:willPresentNotification:userInfo:withCompletionHandler:
- (void)ZPNsNotificationCenter:(UNUserNotificationCenter *) center willPresentNotification:(UNNotification *) notification userInfo:(NSDictionary *) userInfo withCompletionHandler:(void (^)(UNNotificationPresentationOptions)) completionHandler;SDK 离线推送到达通知事件。
Declared in
ZPNs.h参数
| 名称 | 类型 | 描述 |
|---|---|---|
| center | UNUserNotificationCenter * | |
| notification | UNNotification * | |
| userInfo | NSDictionary * | |
| completionHandler | void (^)(UNNotificationPresentationOptions) |
详情
当厂商通知到达展示时,将会触发此回调。
- 业务场景:用于开发者选择是否在应用前台展示推送或者自定义推送的基础行为。
- 支持版本:2.0.0 及以上版本。
