Unity plugin integration with Chrome Custom Tabs for Android
- Open Package Manager in Unity
- Press "+" and "Add package from git URL..."
- Enter this repository and version as
https://github.com/onedevapp/Unity_ChromeCustomTabs.git#TAG(see latest version here)
- You project should build against Android 5.0 (API level 21) SDK at least.
- This plugin uses a custom tool for dependency management called the Play Services Resolver
Once the Browser Library is added to your project there are two sets of possible customizations:
- Customizing the UI and interaction with the custom tabs.
- Making the page load faster, and keeping the application alive.
The UI Customizations are done by using the CustomTabsIntent and the CustomTabsIntent.Builder classes; the performance improvements are achieved by using the CustomTabsClient to connect to the Custom Tabs service, warm-up the browser and let it know which urls will be opened.
The most basic example to launch a Chrome tab is through a custom intent as shown below:
ChromeCustomTab.OpenCustomTab(stringurlToLaunch,stringcolorCode,stringsecColorCode);One of the most important (and simplest to implement) aspects of Custom Tabs is the ability for you to change the color of the address bar to be consistent with your app's theme.
ChromeCustomTab.OpenCustomTab(stringurlToLaunch,stringcolorCode,stringsecColorCode);//"#FF0000" - red
Toggle title in header toolbar
ChromeCustomTab.OpenCustomTab(stringurlToLaunch,stringcolorCode,stringsecColorCode,boolshowTitle);
Hide URL bar on scrolling
ChromeCustomTab.OpenCustomTab(stringurlToLaunch,stringcolorCode,stringsecColorCode,boolshowTitle,boolshowUrlBar);
Register these activities, receivers and queires in the manifest only when ur choosing Custom Main Manifest in Unity
<application> <activity android:name="com.onedevapp.customchrometabs.WebViewActivity"android:exported="true"/> <activityandroid:name="com.onedevapp.customchrometabs.CustomHeadlessActivity"android:theme="@style/Theme.Transparent"android:exported="true"> </activity> <receiverandroid:name="com.onedevapp.customchrometabs.ActionBroadcastReceiver" /> </application> <queries> <intent> <actionandroid:name= "android.support.customtabs.action.CustomTabsService" /> </intent> </queries>If need to use latest version of Custom Tabs in an app, kindly change the required version at below location: Plugins/ChromeCustomTab/Editor/ChromeCustomTabDependencies.xml
Available versions can be found here.
Any contributions are welcome!
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create New Pull Request