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(string urlToLaunch, string colorCode, string secColorCode);
-
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(string urlToLaunch, string colorCode, string secColorCode); //"#FF0000" - red
-
Toggle title in header toolbar
ChromeCustomTab.OpenCustomTab(string urlToLaunch, string colorCode, string secColorCode, bool showTitle);
-
Hide URL bar on scrolling
ChromeCustomTab.OpenCustomTab(string urlToLaunch, string colorCode, string secColorCode, bool showTitle, bool showUrlBar);
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"/>
<activity android:name="com.onedevapp.customchrometabs.CustomHeadlessActivity" android:theme="@style/Theme.Transparent" android:exported="true">
</activity>
<receiver android:name="com.onedevapp.customchrometabs.ActionBroadcastReceiver" />
</application>
<queries>
<intent>
<action android: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