帮助与文档

> >

一、注册账号申请appkey

首先申请appkey,请点击这里

二、下载并导入MobLink

下载Unity-For-MobLink,打开项目双击MobLink.unitypackage相关文件。注意:该操作可能会覆盖您原来已经存在的文件!

三、拖入MobLink并配置其 AppKey

导入unitypackage后,在Plugins - MobLink 中找到MobLink.prefab。将其拖载到您的项目中,如下图示:

iOS配置及注意事项(Android开发者可忽略)

1.Unity切换到iOS环境后,点击以被拖进去的MobLink,在编辑器右侧填入您的AppKey,AppSecret 如下图:

2.预配置Scheme 找到Plugins - iOS - MobLink - Editor - ML.mobpds,对其中的CFBundleURLSchemes进行设定,将其设置为您在MobLink后台填入的 URI Scheme (注意不带'://')

 

 

3.配置Universal Link(本步骤在生成的Xcode中操作)

在生成Xcode项目后,配置在MobLink后台所填入的Universal Link

moblink-unity-ios2

Android配置及注意事项(iOS开发者可忽略)

在这里只需要配置AndroidManifest部分, 请参考原生文档http://wiki.mob.com/sdk-moblink-android-2-0-0/) 中的"配置AndroidManiFest.xml文件"进行配置

1 유튜브 광고 다운로드. 添加权限:

<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

2 애니메이션 카 다운로드. 指定Application使用MobLinkUnityApplication:

android:name="com.mob.moblink.unity.MobLinkUnityApplication"

3 다운로드. 配置应用key:

<meta-data android:name="Mob-AppKey" android:value="Mob后台的AppKey"/>
<meta-data android:name="Mob-AppSecret"  android:value="Mob后台的AppSecret"/>

4 다운로드. 指定启动Activity为MobUnityPlayerActivity:

<activity android:name="com.mob.moblink.unity.MobUnityPlayerActivity"
    android:label="@string/app_name"
    android:clearTaskOnLaunch="false"
    android:launchMode="singleInstance" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>

5 인트루더 다운로드. 添加MobLinkActivity:

<activity
    android:name="com.mob.moblink.MobLinkActivity"
    android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
    android:launchMode="singleTask">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="您的scheme" android:host="您的Host" />
    </intent-filter>
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:host="host从后台配置中取" android:scheme="http"/>
        <data android:host="host从后台配置中取" android:scheme="https"/>
    </intent-filter>
</activity>

6.Mob开发者后台配置“基础配置”参考:

为应用添加URI Scheme,专业版App Links是由Mob自动生成,不需要开发者手动配置。经典版还是需要开发者手动配置App Links。

7.至此,结合上图,完整的AndroidManifest.xml内容大致如下:

<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
    android:name="com.mob.moblink.unity.MobLinkUnityApplication"
    android:theme="@style/UnityThemeSelector"
    android:icon="@drawable/app_icon"
    android:label="@string/app_name"
    android:debuggable="true">
    <meta-data android:name="Mob-AppKey" android:value="Mob后台的AppKey"/>
    <meta-data android:name="Mob-AppSecret" android:value="Mob后台的AppSecret"/>
    <activity 
		android:name="com.mob.moblink.unity.MobUnityPlayerActivity"
        android:label="@string/app_name"
		android:clearTaskOnLaunch="false"
		android:launchMode="singleInstance" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
			<category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </activity>
	<activity 
		android:name="com.mob.moblink.MobLinkActivity" 
		android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
		android:launchMode="singleTask">
		<intent-filter>
			<action android:name="android.intent.action.VIEW"/>
			<category android:name="android.intent.category.DEFAULT"/>
			<category android:name="android.intent.category.BROWSABLE"/>
			<data android:host="com.mob.moblink.demo" android:scheme="mlink"/>
		</intent-filter>
		<intent-filter android:autoVerify="true">
			<action android:name="android.intent.action.VIEW"/>
			<category android:name="android.intent.category.DEFAULT"/>
			<category android:name="android.intent.category.BROWSABLE"/>
			<data android:host="1q.t4m.cn" android:scheme="http"/>
			<data android:host="1q.t4m.cn" android:scheme="https"/>
		</intent-filter>
	</activity>
</application>

四、调用接口及获取回调

1 、编写和设置场景还原的回调

// 全局的场景还原监听函数
protected static void OnRestoreScene(MobLinkScene scene)
{
	Console.Write ("path:" + scene.path);
	Console.Write ("source:" + scene.source);
	Console.Write ("params:" + MiniJSON.jsonEncode (scene.customParams));
}

 

一般在第一个场景的MonoBehaviour.Start()函数中设置监听

protected void Start () 
{
	MobLink.setRestoreSceneListener (OnRestoreScene);
}

 

2 、编写mobid的回调和调用获取mobid

// 获取mobid的回调
void mobIdHandler (string mobid)
{
	Console.Write ("Received MobId:" + mobid);
}

 

Hashtable custom = new Hashtable ();
custom ["ChapterID"] = 1001;
custom ["ChapterName"] = "Dragon Fire";
//构造场景参数
MobLinkScene scene = new MobLinkScene ("/chapter1/dragon", "userid-123456", custom);
//获取mobid
MobLink.getMobId (scene, mobIdHandler);

 

相关文档