GetSocial Android SDK Manual Integration Guide¶
Basic Setup¶
Configure SDK Dependencies¶
GetSocial SDK is distributed as an Android Library in aar
format. You can get it from our Maven Repository or Downloads page in the documentation.
- In your project, open
build.gradle
. -
Add GetSocial Maven Repository to the list of project dependencies repositories:
repositories { maven { url 'https://maven.getsocial.im/' } }
-
Add SDK dependency to your
build.gradle
:dependencies { implementation('im.getsocial:getsocial-core:[7,8)@aar') implementation('im.getsocial:getsocial-ui:[7,8)@aar') // Note: add this dependency only if you plan to use GetSocial UI implementation 'com.android.installreferrer:installreferrer:1.0' // Optional. GetSocial is using it to obtain more accurate data about installs and make attribution more reliable }
-
Build your project.
- Add
getsocial.json
file to your project’sassets
folder. -
Import GetSocial SDK into your app:
import im.getsocial.sdk.GetSocial;
Configure Manifest¶
In this step, we will add your GetSocial App Id to your app and update your Android manifest with required permissions.
- Get your GetSocial App Id from the “App settings” section on the GetSocial Dashboard:
-
Open your module-level build.gradle and add:
android { defaultConfig { manifestPlaceholders = [getsocial_scheme: "[app_id_from_step_1]", getsocial_hostName_0:"[your_invite_url_domain0]", getsocial_hostName_1:"[your_invite_url_domain1]"] } ... }
This step is required for manual initialization as well.
Smart Invites¶
Add Image Content Provider¶
To be able to attach images to the Smart Invite messages you have declare an Image Content Provider:
- Open
AndroidManifest.xml
in your project. -
Add GetSocial Image Content Provider to the
application
element:<provider android:name="im.getsocial.sdk.invites.ImageContentProvider" android:authorities="${applicationId}.smartinvite.images.provider" android:grantUriPermissions="true" android:exported="true"/>
Configure Dependencies¶
To obtain more accurate data about installs and make attribution more reliable, GetSocial is using Google Play Install Referrer API. To add library to your project:
- Open the Android application project
build.gradle
. -
Add library to the dependencies list:
dependencies { ... implementation 'com.android.installreferrer:installreferrer:1.1' }
Using Gradle version before 3.0?
Starting from version 3.0.0 Gradle deprecated
compile
dependency scope and replaced withimplementation
. If you are using Gradle version before 3.0.0, replaceimplementation
keyword withcompile
to avoid build errors.
Url Scheme Configurations¶
Setup Url Schemes for Android 4+¶
- In your project, open
AndroidManifest.xml
. -
Add following intent filter to the activity that should be opened from the deep link. Do not forget to put your GetSocial App Id into the data tag:
<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="[put your getsocial app id here]" android:scheme="getsocial"/> </intent-filter>
-
To validate the configuration, send a Smart Invite and click on the link, your app should be opened:
Setup App Links for Android 6+¶
To improve user experience on clicking the GetSocial Smart Invites link we highly recommend setup Android App links in your app in addition to Url Schemes.
Android 6.0 (API level 23) and higher allow an app to designate itself as the default handler for a given type of link. App Links allow taking the user directly to the app on the link click without the browser window in the middle. Check the official Android App Links docs for more details.
To set up App Links support follow the next steps:
- To setup App Links in your app open
AndroidManifest.xml
in your project. -
Copy Smart Link domain from the GetSocial Dashboard.
There are two options:
- If you are using prefix for the default
gsc.im
domain for Smart Links, you have to add intent filter with the following host configurations to the activity that must be opened from the Smart Link:
<data android:scheme="https" android:host="[PREFIX].gsc.im" /> <data android:scheme="https" android:host="[PREFIX]-gsalt.gsc.im" />
- If you are using custom domain for Smart Links you have to specify both, custom domain and default
gsc.im
domain configurations:
<data android:scheme="https" android:host="[YOUR_CUSTOM_DOMAIN]" /> <data android:scheme="https" android:host="[PREFIX].gsc.im" />
For instance for our Documentation Demo app we use prefix for
gsc.im
domain for Smart Links, intent filter that must be added will be the following:<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:scheme="https" android:host="getdocs.gsc.im" /> <data android:scheme="https" android:host="getdocs-gsalt.gsc.im" /> </intent-filter>
- If you are using prefix for the default
-
To validate configuration:
-
Go to “App info” → “Open by default”, domain(s) specified in the intent filter should be listed in “Supported links” section:
-
Send a Smart Invite and click on the link, and the app selector screen with your app should be opened, or you have to be taken to the app directly.
-
Push Notifications¶
Enable/Disable GetSocial Notifications on the Client Side¶
Specify special meta-tag in AndroidManifest.xml
:
<application ...>
...
<meta-data
android:name="im.getsocial.sdk.AutoRegisterForPush"
android:value="false" />
</application>
Show Notifications In Foreground¶
Specify special meta-tag in AndroidManifest.xml
:
<application ...>
...
<meta-data
android:name="im.getsocial.sdk.ShowNotificationInForeground"
android:value="true" />
</application>
UI Configuration¶
Configuration Loading¶
Set a path to configuration file or directory in your AndroidManifest.xml
:
<application ...>
...
<meta-data
android:name="im.getsocial.sdk.UiConfigurationFile"
android:value="getsocial/ui-landscape.json" />
</application>