Skip to content

Unity plugin helps you in include Android Chrome custom tabs feature

Notifications You must be signed in to change notification settings

onedevapp/Unity_ChromeCustomTabs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

14 Commits

Repository files navigation

Unity Chrome Custom Tabs

Unity plugin integration with Chrome Custom Tabs for Android

INSTALLATION

  • 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)

Requirements

  • 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

How To

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.

Opening a Custom Tab

The most basic example to launch a Chrome tab is through a custom intent as shown below:

ChromeCustomTab.OpenCustomTab(stringurlToLaunch,stringcolorCode,stringsecColorCode);

Configure the color of the address bar

  • 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);

AndroidManifest

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>

Note

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.

👐 Contributions

Any contributions are welcome!

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create New Pull Request



About

Unity plugin helps you in include Android Chrome custom tabs feature

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •