Unity打包出来的app跳转网页,并从网页调转回app(ios,Android)
1.https://www.jianshu.com/p/eed01a661186 ios Scheme讲解
2.https://www.jianshu.com/p/da801097c79d Android Scheme讲解
3.https://blog.csdn.net/qq_16628781/article/details/51539715 Android调用
ios中:
Info -> URL Types设置URL Schemes,然后这个时候打包到手机中
在Safari浏览器中输入 : yigedemohahaha:// 就可以跳回应用...
Android中:
需要在你工程的AndroidMainifest.xml中注册一下:
我是这样写的:
<intent-filter> <data android:host="yigedemo" android:scheme="hahaha" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LEANBACK_LAUNCHER" /> </intent-filter>
详情参照置顶的第二个链接..
网页中:
<a href="hahaha://yigedemo">详情</a>
然后UnityPlayerActivity中的 onNewIntent 方法中调用,参考第三个链接的博文...
@Override protected void onNewIntent(Intent intent) { // To support deep linking, we need to make sure that the client can get access to // the last sent intent. The clients access this through a JNI api that allows them // to get the intent set on launch. To update that after launch we have to manually // replace the intent with the one caught here. setIntent(intent); Uri uri = intent.getData(); String url = uri.toString(); String query = uri.getQuery(); Log.e("TurnURL", "query: "+query ); if (query!=null&&query!="") { Log.e("TurnURL", "url: "+url ); String scheme = uri.getScheme(); Log.e("TurnURL", "scheme: "+scheme ); String host = uri.getHost(); Log.e("TurnURL", "host: "+host ); int port = uri.getPort(); Log.e("TurnURL", "port: "+port ); String path = uri.getPath(); Log.e("TurnURL", "path: "+path ); String goosID = uri.getQueryParameter("goosId"); Log.e("TurnURL", "goosID: "+goosID ); } }