Best implementation of MobPush specified page jump

Time:2022-11-17

Use Scheme to jump to specified page

iOS client code configuration

Please implement the following code in the specified VC that needs to be jumped to, where mlink://com.mob.mobpush.link is the restore path identifier

#import <MobPush/MobPush.h>

#pragma mark ---Scene restoration---
//Click to push the scene to restore the path
+ (NSString *)MobPushPath
{
    return @"mlink://com.mob.mobpush.link";
}
//Click to push the scene to restore page parameters
- (instancetype)initWithMobPushScene:(NSDictionary *)params
{
    if (self = [super init])
    {
        //self.params = params;
    }
    return self;
}

Android client code configuration

Configure the activity corresponding to the specified landing page in AndroidMainfest

 <activity android:name="com.markliu.pushdemo.MainActivity2" android:exported="true"   android:launchMode="singleTask">

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data
                    android:host="com.mob.mobpush.link"
                    android:scheme="mlink" />
            </intent-filter>
        </activity>

MobPush background push configuration

Best implementation of MobPush specified page jump

via REST APIs

Best implementation of MobPush specified page jump

For details, refer to the push interface

Through the notification callback, process the corresponding parameters to jump

iOS callback method settings

//Add notification monitoring, after monitoring, the push parameters can be obtained through the corresponding method 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMessage:) name:MobPushDidReceiveMessageNotification object:nil];

Android-side callback (Android-side manufacturer’s message needs to be processed by parsing the intent, refer to the best implementation of parsing parameters)

This message callback can only handle TCP messages, vendor messages need to parse the intent

MobPushReceiver mobPushReceiver = new MobPushReceiver() {

            @Override
            public void onCustomMessageReceive(Context context, MobPushCustomMessage message) {
                //Received a custom message (transparent message)
                message.getMessageId();//Get task ID
                message.getContent();//Get push content
            }

            @Override
            public void onNotifyMessageReceive(Context context, MobPushNotifyMessage message) {
                //received notification message
                message.getMobNotifyId();//Get message ID
                message.getMessageId();//Get task ID
                message.getTitle();//Get push title
                message.getContent();//Get push content
//                Log.i(TAG, "onCreate: aaaa");
                System.out.println("-------------JsonSchemeShouyeoncreate I received a callback: "+"11111111");
//                System.out.println("-------------markLiujsonOncrearte:"+ message.getContent());
            }

            @Override
            public void onNotifyMessageOpenedReceive(Context context, MobPushNotifyMessage message) {
                //notify clicked event
                message.getMobNotifyId();//Get message ID
                message.getMessageId();//Get task ID
                message.getTitle();//Get push title
                message.getContent();//Get push content
                System.out.println("-------------JsonSchemeShouyeoncreate print view: "+"11111111");
            }

            @Override
            public void onTagsCallback(Context context, String[] tags, int operation, int errorCode) {
                // label operation callback
                //tags: the tag that RegistrationId has added
                //operation: 0 get label 1 set label 2 delete label
                //errorCode: 0 operation succeeds, non-0 operation fails
            }

            @Override
            public void onAliasCallback(Context context, String alias, int operation, int errorCode) {
                //alias operation callback
                //alias: Alias ​​corresponding to RegistrationId
                //operation: 0 get alias 1 set alias 2 delete alias
                //errorCode: 0 operation succeeds, non-0 operation fails
            }

        };
        MobPush.addPushReceiver(mobPushReceiver);

Best implementation for parsing parameters

Best implementation for parsing parameters