tencent cloud

Feedback

Last updated: 2024-07-04 17:01:08
    TUICallKit components support offline push through the integration of the push plugin. To help developers easily implement offline push in their projects, we recommend using the TIMPush plugin (paid). TIMPush push plugin has the following advantages:
    Short integration period, it is estimated that integration with all vendors only takes 30 minutes.
    Supports data statistics and link tracking, making it easy for you to view various metrics such as reach rate, click-through rate, and conversion rate.
    Supports All-staff/Tag Push, making it convenient to push marketing ads, notifications, news information, etc., to all users or specific groups.
    Supports cross-platform frameworks like uni-app and Flutter.

    Integration effect

    Lock Screen Effects
    Effects When in the Background
    
    
    
    
    
    

    Configure Offline Push

    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
    pod 'TIMPush', '7.9.5668'
    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 the local CocoaPods repository list. pod repo update

    Step 2: Enable App Remote Push

    1. Log in to the Apple Developer Center website, and click on  Identifiers to enter the Certificates, Identifiers & Profiles page.
    
    
    
    2. Click the + next to Identifiers.
    
    
    
    3. You can follow the steps below to create a new AppID, or add a Push Notification Service to your existing AppID.
    Note
    Please note that the Bundle ID of your App cannot use the wildcard *, otherwise the remote push service cannot be used.
    4. Check App IDs, click Continue to proceed.
    5. Select App and click Continue to proceed.
    6. Configure Bundle ID and other information, then click Continue to proceed.
    7. Check Push Notifications to enable the remote push service.
    
    
    

    Step 3: Generate Push Certificates

    1. Select your AppID, select the Push Notifications configuration item, and click Configure.
    
    
    
    2. You can see two SSL Certificates in the Apple Push Notification service SSL Certificates window, which are used for the remote push certificates of the development environment and production environment, as shown in the picture below:
    3. 
    F
    irst, select Create Certificate for the development environment. The system will prompt us to upload a Certificate Signing Request (CSR).
    4. Next, create a CSR file. Open Keychain Access on your Mac, and in the menu, choose Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority.
    
    
    
    5. Enter your email address, common name (your name or company name), choose Save to disk, click Continue, and the system will generate a *.certSigningRequest file.
    6. Go back to the Apple Developer website in Step3 , click Choose File and upload the generated *.certSigningRequest file.
    
    
    
    7. Click Continue to generate the push certificate.
    8. Click Download to save the Development SSL Certificate locally.
    9. Repeat steps 1 to 8 to download the Production SSL Certificate for the production environment.
    Note
    The production environment certificate is actually a combined certificate of development (Sandbox) and production (Production) environments, which can be used as certificates for both development and production environments.
    10. Double-click the downloaded development and production environment SSL Certificates, and the system will import them into the keychain.
    11. Open the Keychain app, under Login > My Certificates, right-click on the created VoIP Services certificate.
    Note
    When saving the P12 file, please be sure to set a password for it.

    Step 4:Upload certificates to the IM ConsoleBefore integrating the message push plugin, you need to apply to Apple for an APNs push certificate, then upload the push certificate to the Tencent RTC Console.

    Operation step

    Step 1: Apply for an APNs certificate

    Activate remote push for the App

    1. log in to Apple Developer Center Web Sites, click Certificates, Identifiers & Profiles or the sidebar's Certificates, IDs & Profiles, to enter the Certificates, IDS & Profiles page.
    
    
    
    2. click on the identifier's right +.
    
    
    
    3. You can follow the steps below to create a new AppID, or add the Push Notification Service to your existing AppID.
    Note:
    Your App's Bundle ID cannot use the wildcard *; otherwise, the remote push service cannot be used.
    4. Select App IDs, click Continue to proceed to the next step.
    
    
    
    5. Select App, click Continue to proceed to the next step.
    
    
    
    6. Configure Bundle ID and other information, click Continue to proceed to the next step.
    
    
    
    7. Select Push Notifications to activate the remote push service.
    
    
    

    Certificate Generation

    1. Select your AppID and choose Configure.
    
    
    
    2. You can see in the Apple Push Notification Service SSL Certificates window, there are two SSL Certificates, one for the development environment (Development) and the other for the production environment (Production) remote push certificates, as shown below:
    
    
    
    3. 
    We
    first select the development (Development) environment's Create Certificate, and the system will prompt you that a Certificate Signing Request (CSR) is required.
    
    
    
    4. Open Keychain Access tool (Keychain Access) on Mac, select Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority (Keychain Access - Certificate Assistant - Request a Certificate From a Certificate Authority).
    
    
    
    5. Enter your email address (Your email), Common Name (Your name or company name), choose Save to disk, click continue, and the system will generate a *.certSigningRequest file.
    
    
    
    6. Return to the Apple Developer Website page mentioned in Step 3 above, click Choose File to upload the generated *.certSigningRequest file.
    
    
    
    7. Click Continue to generate the push certificate.
    
    
    
    8. Click Download to download the Development SSL Certificate for your development environment to your local system.
    
    
    
    9. Follow the steps 1-8 again to download the Production SSL Certificate for your production environment to your local system.
    Note:
    The certificate for the production environment is actually a merged Sandbox and Production certificate, which can be used for both development and production environments.
    
    
    
    
    
    
    10. Double-click the downloaded SSL Certificate for both the development and production environments, and the system will import it into your keychain.
    11. Open the Keychain application, navigate to log in to My Certificates, and right-click to export the newly created Development (Apple Development IOS Push Service) and Production (Apple Push Services) environment's P12 files.
    Note:
    When saving the P12 file, be sure to set a password.

    Step 2: Upload the certificate to the console

    1. Log in to the Tencent RTC Console.
    2. Click on the Target Application Card, select the Chat Tag on the left, click on Push, then click on Access settings.
    
    
    
    3. Click on iOS Native Offline Push Settings on the right side to Add Certificate.
    4. Select Certificate Type, upload the iOS Certificate (p12), set the Certificate Password, and click on Confirm.
    
    
    
    Note
    We recommend naming the uploaded certificate in English (special characters such as brackets are not allowed).
    You need to set a password for the uploaded certificate. Without a password, push notifications cannot be received.
    For an app published on App Store, the environment of the certificate must be the production environment. Otherwise, push notifications cannot be received.
    The uploaded .p12 certificate must be your own authentic and valid certificate.
    5. Once the push certificate information is generated, record the certificate ID. It will be used as a mandatory parameter in Step 6: Configure Push Parameters.
    

    Step 5:Complete Project Configuration

    To add the required permissions in your application, enable push notification functionality in your Xcode project.
    Open your Xcode project, go to Project > Target > Capabilities, click +, and select and add Push Notifications. The added result is shown in the yellow frame in the image below:
    
    
    

    Step 6: Configure Push Parameters

    You need to implement the protocol method offlinePushCertificateID in AppDelegate to return the Certificate ID.
    Swift
    Objective-C
    import TIMPush
    
    func offlinePushCertificateID() -> Int32 {
    return kAPNSBusiId
    }
    #pragma mark - TIMPush
    
    - (int)offlinePushCertificateID {
    return kAPNSBusiId;
    }

    Step 7: Dial Offline Push Calls

    Please set the offlinePushInfo field of params when making a call using call or groupCall.
    Swift
    Objective-C
    import TUICallKit_Swift
    import TUICallEngine
    
    let pushInfo: TUIOfflinePushInfo = TUIOfflinePushInfo()
    pushInfo.title = ""
    pushInfo.desc = "You have a new call"
    pushInfo.iOSPushType = .apns
    pushInfo.ignoreIOSBadge = false
    pushInfo.iOSSound = "phone_ringing.mp3"
    pushInfo.androidSound = "phone_ringing"
    // For OPPO, you must set the `ChannelID` to receive push messages. The `ChannelID` must be identical with that in the console.
    // OPPO must set a ChannelID to receive push messages. This channelID needs to be the same as the console.
    pushInfo.androidOPPOChannelID = "tuikit"
    // FCM channel ID, you need change PrivateConstants.java and set "fcmPushChannelId"
    pushInfo.androidFCMChannelID = "fcm_push_channel"
    // VIVO message type: 0-push message, 1-System message(have a higher delivery rate)
    pushInfo.androidVIVOClassification = 1
    // HuaWei message type: https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/message-classification-0000001149358835
    pushInfo.androidHuaWeiCategory = "IM"
    
    let params = TUICallParams()
    params.userData = "User Data"
    params.timeout = 30
    params.offlinePushInfo = pushInfo
    
    // Single person call example, similar for group call
    TUICallKit.createInstance().call(userId: "123456", callMediaType: .audio, params: params) {
    
    } fail: { code, message in
    
    }
    #import <TUICallKit_Swift/TUICallKit_Swift-Swift.h>
    #import <TUICallEngine/TUICallEngine.h>
    
    - (TUICallParams *)getCallParams {
    TUIOfflinePushInfo *offlinePushInfo = [self createOfflinePushInfo];
    TUICallParams *callParams = [TUICallParams new];
    callParams.offlinePushInfo = offlinePushInfo;
    callParams.timeout = 30;
    return callParams;
    }
    
    - (TUIOfflinePushInfo *)createOfflinePushInfo {
    TUIOfflinePushInfo *pushInfo = [TUIOfflinePushInfo new];
    pushInfo.title = @"";
    pushInfo.desc = @"You have a new call";
    pushInfo.iOSPushType = TUICallIOSOfflinePushTypeAPNs;
    pushInfo.ignoreIOSBadge = NO;
    pushInfo.iOSSound = @"phone_ringing.mp3";
    pushInfo.AndroidSound = @"phone_ringing";
    // For OPPO, you must set the `ChannelID` to receive push messages. The `ChannelID` must be identical with that in the console.
    // OPPO must set a ChannelID to receive push messages. This channelID needs to be the same as the console.
    pushInfo.AndroidOPPOChannelID = @"tuikit";
    // FCM channel ID, you need change PrivateConstants.java and set "fcmPushChannelId"
    pushInfo.AndroidFCMChannelID = @"fcm_push_channel";
    // VIVO message type: 0-push message, 1-System message(have a higher delivery rate)
    pushInfo.AndroidVIVOClassification = 1;
    // HuaWei message type: https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/message-classification-0000001149358835
    pushInfo.AndroidHuaWeiCategory = @"IM";
    return pushInfo;
    }
    
    // Single person call example, similar for group call
    [[TUICallKit createInstance] callWithUserId:@"123456"
    callMediaType:TUICallMediaTypeAudio
    params:[self getCallParams] succ:^{
    
    } fail:^(int code, NSString * _Nullable errMsg) {
    
    }];

    Frequently Asked Questions

    Can't receive push notifications and backend reports bad deviceToken error?

    The Apple deviceToken is related to the current compilation environment. If the certificate ID used for uploading the deviceToken to Tencent Cloud after logging in to IMSDK and the token are inconsistent, an error will be reported.
    If you are using a Release environment for compilation, the - application:didRegisterForRemoteNotificationsWithDeviceToken: callback returns the production environment token. In this case, the businessID needs to be set to the production environment Certificate ID.
    If you are using a Debug environment for compilation, the - application:didRegisterForRemoteNotificationsWithDeviceToken: callback returns the development environment token. In this case, the businessID needs to be set to the development environment certificate ID.

    Occasionally, iOS development environment does not return deviceToken or prompts APNs to request token failure?

    This problem is caused by the instability of APNs service. You can try the following solutions:
    1. Insert a SIM card in your phone and test using 4G network.
    2. Test after uninstalling and reinstalling the app, restarting the app, or restarting the device.
    3. Test with a package under the production environment.
    4. Test with other iOS system phones.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support