If you want to integrate the TIMPush component as simply as possible, you need to use the login/logout interfaces of TUILogin for IM account login/logout operations. The TIMPush component can automatically detect login/logout events.
Step 1. Integrate the TIMPush component
1. The TIMPush component supports CocoaPods integration. You need to add the component dependencies in the Podfile.
target 'YourAppName' do
# Uncommment the next line if you're using Swift or would like to use dynamic frameworks
use_frameworks!
use_modular_headers!
# Pods for Example
# The version number "VERSION" can be obtained from the Update Log.
pod 'TIMPush', 'VERSION'
end
2. Run the following command to install the TIMPush component.
pod install
# If you cannot install the latest version of TUIKit, run the following command to update your local CocoaPods repository list.
pod repo update
Step 2. Set push parameters
1. After you upload the certificate to the IM console, the IM console allocates a certificate ID for you, as shown below:
2. You need to implement the - businessID protocol method in AppDelegate to return the certificate ID.
Objective-C
Swift
#pragma mark - TIMPush
-(int)businessID {
//The businessID ID obtained in the previous step in the console, such as 1234567
At this point, you have completed the basic push feature integration.
Note:
1. After you log in, when you see the APNs configuration success log printed on the console, it indicates that the integration is successful.
2. If your app has obtained push permissions, you will receive remote push notifications when it goes to the background or the process is stopped.
3. If you have not integrated the TUICore component and do not need to use TUILogin for login/logout but still want to implement offline push, you only need to:
After your app/IM login is complete, actively call the registerPush method to register for push notifications.
When logging out, actively call the unRegisterPush method to unregister push notifications.
4. If you only want to support push notifications without login, you can switch the registration interface to: call the registerPush interface of TIMPushManager. For details on sending messages in step 3, see - restApi interface.
Step 3. Set offline push parameters when sending messages (TUIChat has already added this by default when integrating with UI, you can skip this step)
When calling sendMessage to send messages, you can set offline push parameters through V2TIMOfflinePushInfo. Use the ext of V2TIMOfflinePushInfo to set custom ext data. When the user receives the offline push and launches the app, they can get the ext field in the callback of clicking the notification and then navigate to the specified UI based on the ext field content. Refer to the sendMessage: method of TUIMessageBaseDataProvider:
//- If NO is returned, TIMPush will continue to execute the built-in TUIKit offline push parsing logic and continue to callback - navigateToBuiltInChatViewController:groupID: method.
//- If YES is returned, TIMPush will not execute the built-in TUIKit offline push parsing logic, leaving it entirely to you to handle.
// let ext = notice
// let info = OfflinePushExtInfo.create(withExtString: ext)
// return true
//- If false is returned, TIMPush will continue to execute the built-in TUIKit offline push parsing logic and continue to callback - navigateToBuiltInChatViewController:groupID: method.
To report push delivery data, enable the mutable-content switch to support iOS 10's extension feature.
Data details can be viewed on the Push Data Page. The Push Data Page can only be used after purchasing the Push Plugin.
About compliance
TIMPush will not perform any other operations before you actively call registerPush, in accordance with relevant regulations.
If you use TUILogin for login and logout, TIMPush will automatically call registerPush or unRegisterPush internally.
Congratulations on completing the integration of the Push Plugin. Please note: After the trial or purchase expiry of the Push Plugin, push services (including regular message offline push, all-staff push, etc.) will be automatically stopped. To avoid affecting the normal use of your business, please purchase/renew in advance.
Regarding All-staff/Tag Push
All-staff/Tag Push supports sending specific content, and also allows for the delivery of personalized content to specific user groups based on Tag, attribute, such as Membership Activities, Regional Notifications, etc. It aids in User Acquisition, Conversion, Activation Promotion, and other operational work phases, while also supporting Push Delivery Reports, Self-service Push Troubleshooting Tool. For more details, please see Effect Display.
For more detailed content, it is recommended to refer to All-staff/Tag Push.
Congratulations on completing the integration of the Push Plugin. Please note: After the trial or purchase expiry of the Push Plugin, push services (including regular message offline push, all-staff push, etc.) will be automatically stopped. To avoid affecting the normal use of your business, please purchase/renew in advance.