tencent cloud

Feedback

Custom Definition Click Redirect

Last updated: 2024-06-13 10:21:45

    Flutter

    Step 1: Manufacturer Configuration

    Refer to Manufacturer Configuration > Flutter, complete the manufacturer configuration. Please note, for subsequent actions after clicking, use the default configuration.
    
    
    

    Step 2: Client Code Configuration

    Refer to Client Code Configuration, complete the configuration.

    Step 3: Handle Message Click Callback and Parse Parameters

    Please define a function for receiving push message click callback events.
    Define the function with the parameter format {required String ext, String? userID, String? groupID}.
    Here, the ext field contains the full ext information carried by the message, specified by the sender. If not specified, there is a default value. You can use this to navigate to the corresponding page based on parsing this field.
    The userID and groupID fields, for this plugin, attempt to automatically parse the ext Json String and obtain the individual chat partner userID and group chat groupID information carried within. If you haven't defined the ext field yourself, and the ext field is specified by default by the SDK or UIKit, you can use the default parsing here. If the parsing attempt fails, they will be null.
    You can define a function to receive this callback and use it to navigate to the corresponding Session Page or your Business Page.
    Example below:
    void _onNotificationClicked({required String ext, String? userID, String? groupID}) { print("_onNotificationClicked: $ext, userID: $userID, groupID: $groupID"); if (userID != null || groupID != null) { // Navigate to the corresponding Message Page based on userID or groupID. } else { // Use your own parsing method based on the ext field to navigate to the corresponding page. } }

    Step 4: Mount the Listen for Callbacks

    After completing the IM Login, and before using other plugins (such as CallKit), immediately register the Push Plugin.
    Invoke the TencentCloudChatPush().registerPush method, pass in the Click Callback Function defined in the background.
    Additionally, you can optionally pass in the apnsCertificateID for the iOS Push Certificate ID and androidPushOEMConfig for Android Push Vendor Configuration. These configurations have been specified in previous steps. If no changes are necessary, they need not be passed in again.
    TencentCloudChatPush().registerPush(onNotificationClicked: _onNotificationClicked);
    Note:
    If your application needs to use the push plugin for business message notifications, and it does not immediately start and log in to the IM module after launching<3>, or you need to handle business navigation through message click callbacks before <5>logging in to the IM module</5>, it is recommended that you call the <7>TencentCloudChatPush().registerOnNotificationClickedEvent</7> method as soon as possible to manually mount the message click callback, in order to timely retrieve message parameters.
    In such scenarios, you can execute this function before calling TencentCloudChatPush().registerPush and place it as early as possible in your code.
    TencentCloudChatPush().registerOnNotificationClickedEvent(onNotificationClicked: _onNotificationClicked);

    Android

    After receiving an offline push, the notification bar will display the push message as shown. Clicking on the notification bar can custom open the application interface.
    
    1. For console configuration, click on 'Subsequent Actions' and configure as follows, choose Open the specified interface within the app, and the plugin users will by default fill in the jump parameters.
    
    
    
    2. For registration and callback handling of click events, it's recommended to place the registration in the application's Application oncreate() function. The component will notify the application via callback or broadcast, and the application can configure its custom jump page in the callback.
    The callback method is as follows:
    TUICore.registerEvent(TUIConstants.TIMPush.EVENT_NOTIFY, TUIConstants.TIMPush.EVENT_NOTIFY_NOTIFICATION, new ITUINotification() {
    @Override
    public void onNotifyEvent(String key, String subKey, Map<String, Object> param) {
    Log.d(TAG, "onNotifyEvent key = " + key + "subKey = " + subKey);
    if (TUIConstants.TIMPush.EVENT_NOTIFY.equals(key)) {
    if (TUIConstants.TIMPush.EVENT_NOTIFY_NOTIFICATION.equals(subKey)) {
    if (param != null) {
    String extString = (String)param.get(TUIConstants.TIMPush.NOTIFICATION_EXT_KEY);
    TUIUtils.handleOfflinePush(extString, null);
    }
    }
    }
    }
    });
    The broadcast method is as follows:
    // Dynamic Broadcast Registration
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(TUIConstants.TIMPush.NOTIFICATION_BROADCAST_ACTION);
    LocalBroadcastManager.getInstance(context).registerReceiver(localReceiver, intentFilter);
    
    // Broadcast Receiver
    public class OfflinePushLocalReceiver extends BroadcastReceiver {
    public static final String TAG = OfflinePushLocalReceiver.class.getSimpleName();
    
    @Override
    public void onReceive(Context context, Intent intent) {
    DemoLog.d(TAG, "BROADCAST_PUSH_RECEIVER intent = " + intent);
    if (intent != null) {
    String ext = intent.getStringExtra(TUIConstants.TIMPush.NOTIFICATION_EXT_KEY);
    TUIUtils.handleOfflinePush(ext, null);
    } else {
    DemoLog.e(TAG, "onReceive ext is null");
    }
    }
    }

    iOS

    Please set the V2TIMOfflinePushInfo's ext field when calling sendMessage to send a message. When the user receives an offline push and starts the App, they can get the ext field in the AppDelegate -> didReceiveRemoteNotification system callback, and then jump to the specified UI interface according to the content of the ext field.
    Taking the scenario of Denny sending a message to Vinson as an example.
    The sender, Denny, needs to set the push extension field ext when sending the message:
    // Denny sets offlinePushInfo and specifies the ext field when sending the message
    V2TIMMessage *msg = [[V2TIMManager sharedInstance] createTextMessage:@"Text Message"];
    V2TIMOfflinePushInfo *info = [[V2TIMOfflinePushInfo alloc] init];
    info.ext = @"jump to denny";
    [[V2TIMManager sharedInstance] sendMessage:msg receiver:@"vinson" groupID:nil priority:V2TIM_PRIORITY_DEFAULT
    onlineUserOnly:NO offlinePushInfo:info progress:^(uint32_t progress) {
    } succ:^{
    } fail:^(int code, NSString *msg) {
    }];
    Recipient: Vinson's App may be offline, but can still receive APNS offline push. When Vinson clicks on the push message, the App will launch:
    // After launching the APP, Vinson will receive the following callback
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
    // Parsing the push extension field desc
    if ([userInfo[@"ext"] isEqualToString:@"jump to denny"]) {
    // Jump to the chat interface with Denny
    }
    }
    
    
    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