This article is intended to provide MobLink's business scenario usage instructions, hoping to bring you a more pleasant development mood:

The function of MobLink is to save the parameter information of the link to the server before sharing. When sharer A shares to his friend B through WeChat, QQ, etc., friend B opens the link and clicks "Open in app" on the page, the webpage js in will try to open the corresponding APP. If the opening fails, js will cache the information of the current device to our server, and then jump to the app download page. After the app is installed and started, our sdk will request the cached parameters from the server, so the app can obtain the parameter information set by the link. If the js is successfully opened, the js will pass the parameters cached in the page to the app by itself. You can also get the parameter information set by the link. For example, if there is no code invitation, you can bind the passed parameters. It is recommended to use the uid. A shares it with B, and B will automatically bind the uid of A after registration.

parameter settings

When sharing the product/content/event page in the app, add the parameter information you need to the shared link.

Set parameter information directly through params on the web page

 <script type="text/javascript" src="//1p.t4m.cn/applink.js"></script>
/*
* MobLink 支持数组=>MobLink([...]) 和对象=>MobLink({...}) 两种初始化形式
* 页面上有多个元素需要跳转时使用数组方式,仅单个元素需要跳转时可以使用对象的方式进行初始化
* el: 表示网页上Element的id值,该字段为空或者不写,则表示MobLink **默认浮层** 上的打开按钮(注意:该字段支持selector方式: 1.'.class' 2.'#id1' 3.['#id1','#id2'])
* path: 对应App里需要恢复页面的路径
* params: 网页需要带给客户端的参数
*/
// 页面上仅单个元素需要跳转时可以使用对象方式进行初始化
MobLink({
 el: '',
 path: 'demo/a',
 params: {
     key1: 'value1',
     key2: 'value2',
 }
})
// 页面上有多个元素需要跳转时要使用数组方式进行初始化
MobLink([
 {
     el: '',
     path: 'demo/a',
     params: {
         key1: 'value1',
         key2: 'value2',
     }
 },
 {
     el: '#openAppBtn1',
     path: 'demo/b',
     params: {
         key1: 'value1',
         key2: 'value2',
     }
 },
 {
     el: '#openAppBtn2',
     path: 'demo/c',
     params: {
         key1: 'value1',
         key2: 'value2',
     }
 }
]);
</script>

Set parameter information through the interface of the client

Generate MobId through the getMobID interface, and splicing the mobid behind your scene restore link.

eg: http://f.moblink.mob.com/pro/scene/novel?id=1&mobid=1467308004604772352

 //java代码
// 设置场景参数
HashMap senceParams = new HashMap();
senceParams.put("key1", "value1");
senceParams.put("key2", "value2");
senceParams.put("key3", "value3");

// 新建场景
Scene s = new Scene();
s.path = "/demo/a";
s.params = senceParams;

// 请求场景ID
MobLink.getMobID(s, new ActionListener() {
    public void onResult(String mobID) {
        // TODO 根据mobID进行分享等操作
    }

    public void onError(Throwable throwable) {
        // TODO 处理错误结果
    }
});

Parameter acquisition <br>Get the parameter information set in the link through the SceneRestorable interface on the specified jump page. You can use these parameters to make a logical judgment to achieve the functions you need, such as diversified jumps, no-code invitations, and the source can be Traceability and other functions

 //java代码
public class RestoreSenceActivity extends Activity implements SceneRestorable {
    @Override
    public void onReturnSceneData(Scene scene) {
       // 处理场景还原数据, 可以在这里做更新画面等操作
    }
    @Override
       // 必须重写该方法,防止MobLink在某些情景下无法还原
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        MobLink.updateNewIntent(getIntent(), this);
   }
}

中关村科金
136 声望13 粉丝

北京中关村科金技术有限公司(简称“中关村科金”)是国内领先的对话式AI技术解决方案提供商,成立于2014年,注册资本14亿元,总部位于北京,在上海、重庆、深圳、杭州、成都等地设有分支机构,公司规模近千人,其...