TIMPushManager, TIMPushListener, TIMPushDelegate, TIMPushMessage, callback types, and error codes.TIMPushManager is the push service manager class of the TIMPush iOS SDK. Use it to register the push service, manage RegistrationID, configure foreground notification display, add listeners, and measure push arrival in the Notification Service Extension.API | Description |
Registers the push service. | |
Unregisters the push service. | |
Gets the current push registration ID. | |
Sets a custom push registration ID. | |
Sets whether to show a notification when the app receives a push in the foreground. | |
Adds a push listener. | |
Removes a push listener. | |
Handles a push request in the Notification Service Extension to measure push arrival. |
TIMPushListener is the push event listener protocol. After implementing it, you can receive push messages, push recall events, and notification click events. The protocol is not marked @optional; implement all three methods.API | Description |
Called when a push message is received. | |
Called when a push message recall notification is received. | |
Callback when a notification bar message is clicked. |
TIMPushDelegate is the protocol for offline push certificate configuration and click-event handling. It inherits from UIApplicationDelegate, and all methods are optional.API | Description |
Returns the offline push certificate ID. | |
Returns the App Group ID shared by the main app and the Notification Service Extension. | |
Custom handling for a received remote push. | |
Handles page navigation after a notification is tapped. |
typedef void(^TIMPushCallback)(void);
typedef void(^TIMPushValueCallback)(NSString *value);
Parameter | Type | Description |
value | NSString * | String value returned by the callback. |
typedef void(^TIMPushSuccessCallback)(NSData *deviceToken);
Parameter | Type | Description |
deviceToken | NSData * | Device token returned by APNs. |
typedef void(^TIMPushFailedCallback)(int code, NSString *desc);
Parameter | Type | Description |
code | int | Error code. |
desc | NSString * | Error description. |
typedef void(^TIMPushCallExperimentalAPISucc)(NSObject *object);
Parameter | Type | Description |
object | NSObject * | Data object returned by an experimental API. The concrete type depends on the API definition. |
typedef void(^TIMPushNotificationExtensionCallback)(UNNotificationContent *content);
Parameter | Type | Description |
content | UNNotificationContent * | Processed notification content. |
+ (void)registerPush:(int)sdkAppIdappKey:(NSString *)appKeysucc:(TIMPushSuccessCallback)successCallbackfail:(TIMPushFailedCallback)failedCallback;
Parameter | Type | Description |
sdkAppId | int | SDKAppID of the Push app. |
appKey | NSString * | Client key of the Push app. |
successCallback | TIMPushSuccessCallback | Registration success callback. The callback carries the deviceToken returned by APNs. |
failedCallback | TIMPushFailedCallback | Registration failure callback. The callback carries the error code and error description. |
sdkAppId and appKey values to register the push service.appKey to nil to enable offline push.+ (void)unRegisterPush:(TIMPushCallback)successCallbackfail:(TIMPushFailedCallback)failedCallback;
Parameter | Type | Description |
successCallback | TIMPushCallback | Unregistration success callback. |
failedCallback | TIMPushFailedCallback | Unregistration failure callback. The callback carries the error code and error description. |
login and logout capabilities provided by TUILogin, you do not need to call this API separately.+ (void)getRegistrationID:(TIMPushValueCallback)callback;
Parameter | Type | Description |
callback | TIMPushValueCallback | Get success callback. The callback returns the current push ID. |
registrationID (device ID), which may change after uninstall and reinstall.userID.registerPush:appKey:succ:fail:; otherwise you may not get a value. When sending test messages from the console or server, use the returned value to identify the device or user.+ (void)setRegistrationID:(NSString *)registrationIDcallback:(TIMPushCallback)callback;
Parameter | Type | Description |
registrationID | NSString * | Custom push registration ID. |
callback | TIMPushCallback | Set completion callback. |
RegistrationID to push messages to a specific device, call this API before registerPush:appKey:succ:fail:.+ (void)disablePostNotificationInForeground:(BOOL)disable;
Parameter | Type | Description |
disable | BOOL | YES: disable foreground notification display; NO: enable foreground notification display. |
YES.disablePostNotificationInForeground(disable:)
+ (void)addPushListener:(id<TIMPushListener>)listener;
Parameter | Type | Description |
listener | id<TIMPushListener> | Push listener object. |
TIMPushListener.addPushListener(listener:)
+ (void)removePushListener:(id<TIMPushListener>)listener;
Parameter | Type | Description |
listener | id<TIMPushListener> | Push listener object to remove. |
removePushListener(listener:)
+ (void)handleNotificationServiceRequest:(UNNotificationRequest *)requestappGroupID:(NSString *)appGroupIDcallback:(TIMPushNotificationExtensionCallback)callback;
Parameter | Type | Description |
request | UNNotificationRequest * | The notification request received by UNNotificationServiceExtension. |
appGroupID | NSString * | App Group ID shared by the main app and the Notification Service Extension. |
callback | TIMPushNotificationExtensionCallback | Completion callback. The callback carries the processed notification content. |
didReceiveNotificationRequest:withContentHandler:.AppDelegate, implement the TIMPushDelegate method applicationGroupID and return the App Group ID.handleNotificationServiceRequest(request:appGroupID:callback:)
TIMPushListener protocol is not marked @optional. When you implement it, you must implement all three methods: onRecvPushMessage:, onRevokePushMessage:, and onNotificationClicked:.Callback | Trigger timing |
onRecvPushMessage: | Triggered when the app is online and receives a Chat message that includes offlinePushInfo. |
onRevokePushMessage: | Triggered when the app is online and receives a message recall notification. |
onNotificationClicked: | Triggered when the user taps a notification bar message. This includes cases where the app is offline, the message is delivered via APNs / Notification Service Extension, and tapping the notification launches the app. |
offlinePushInfo. This callback is not triggered if the app process has already exited.- (void)onRecvPushMessage:(TIMPushMessage *)message;
Parameter | Type | Description |
message | TIMPushMessage * | Push message object. |
- (void)onRevokePushMessage:(NSString *)messageID;
Parameter | Type | Description |
messageID | NSString * | Unique ID of the recalled message. |
- (void)onNotificationClicked:(NSString *)ext;
Parameter | Type | Description |
ext | NSString * | Offline message passthrough field. |
TIMPushDelegate is used to configure the offline push certificate and to take over remote push handling and post-click navigation. This protocol inherits from UIApplicationDelegate, and all methods are optional.- (int)businessID;
AppDelegate and return the offline push certificate ID assigned in the console.- (NSString *)applicationGroupID;
AppDelegate. If you need to measure push arrival rates on iOS 10 and later, implement this method and return the configured App Group ID. The value must match the appGroupID passed to handleNotificationServiceRequest:appGroupID:callback:.- (BOOL)onRemoteNotificationReceived:(nullable NSString *)notice;
Parameter | Type | Description |
notice | NSString * _Nullable | Remote push notification content. |
AppDelegate.YES means your business has handled the push, and TIMPush will no longer run the built-in TUIKit offline push parsing logic.NO means TIMPush continues the built-in TUIKit offline push parsing logic and continues to call navigateToBuiltInChatViewController:groupID:.- (void)navigateToBuiltInChatViewController:(nullable NSString *)userIDgroupID:(nullable NSString *)groupID;
Parameter | Type | Description |
userID | NSString * _Nullable | One-to-one chat user ID. |
groupID | NSString * _Nullable | Group chat ID. |
userID and groupID from the offline push. If groupID is not empty, the tap is for a group chat offline message. If groupID is empty and userID is not empty, the tap is for a one-to-one offline message.navigateToBuiltInChatViewController(userID:groupID:)
TIMPushMessage represents a push message object.Property | Type | Description |
title | NSString * | Offline push title. |
desc | NSString * | Offline push content. |
ext | NSString * | Offline push passthrough content. |
messageID | NSString * | Unique message ID. |
TIMPushErrorCode defines the business error codes of the TIMPush SDK.Error code | Value | Description |
TIMPushErrorUndefinedCode | -1 | Unknown error. |
TIMPushErrorNotLogined | 800001 | Chat account not logged in before registering push. |
TIMPushErrorInvalidSdkAppId | 800002 | Invalid sdkAppId parameter for push registration. |
TIMPushErrorRegisterPushInitFailed | 800003 | Failed to initialize the SDK. |
TIMPushErrorCallExperimentalApiFailed | 800015 | Experimental API call failed. |
TIMPushErrorNotificationAuthorizationDenied | 800016 | The user denied notification permission. |
TIMPushErrorHttpsRequestFailed | 800017 | HTTPS request failed. |
フィードバック