Skip to content

Commit

Permalink
Prepare 3.0.0 release (#65)
Browse files Browse the repository at this point in the history
* Prepare 3.0.0 release

* Update README.md

* Update android-wrapper build.gradle

* Update package
  • Loading branch information
nzagorchev authored Jan 15, 2024
1 parent 4b1322a commit d711384
Show file tree
Hide file tree
Showing 26 changed files with 785 additions and 129 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Change Log
==========

Version 3.0.0 *(15 Jan, 2024)*
-------------------------------------------
- Updated to [CleverTap Android SDK v6.0.0](https://github.com/CleverTap/clevertap-android-sdk/releases/tag/corev6.0.0)
- Updated to [CleverTap iOS SDK v6.0.0](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/6.0.0)
- Support `DateTime` objects for `ProfilePush`, `OnUserLogin`, `RecordEvent` and `RecordChargedEventWithDetailsAndItems`
- Support for [Product Experiences - Remote Config/Variables](docs/Variables.md)
- Unity Package Manager support
- CleverTap structure and interface changes:
- Use the static `CleverTap.cs` methods.
- `CleverTapBinding.cs` and `CleveTapUnity.cs` are now obsolete. They are still usable with minor changes but will be removed in the future.
- Improved mechanism to handle callbacks - add an event listener for a callback directly through the `CleverTap` static events. _No need_ to set all callbacks in the `CleverTapUnity.cs` _anymore_.
- iOS Settings are configured from Assets -> CleverTap Settings
- CleverTap SDK uses EDM4U for dependency management


Version 2.4.2 *(24 October, 2023)*
-------------------------------------------
- Profile APIs support for multiple data types
Expand Down
2 changes: 1 addition & 1 deletion CTExporter/ProjectSettings/AndroidResolverDependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package>androidx.core:core:1.9.0</package>
<package>com.android.installreferrer:installreferrer:2.2</package>
<package>com.clevertap.android:clevertap-android-sdk:5.2.1</package>
<package>com.clevertap.android:clevertap-android-sdk:6.0.0</package>
<package>com.google.firebase:firebase-messaging:23.0.6</package>
</packages>
<files />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repositories {
dependencies {
compileOnly fileTree('libs')

implementation 'com.clevertap.android:clevertap-android-sdk:5.2.1'
implementation 'com.clevertap.android:clevertap-android-sdk:6.0.0'
implementation 'com.google.firebase:firebase-messaging:23.0.6'
implementation 'androidx.core:core:1.9.0'
}
}
2 changes: 1 addition & 1 deletion CleverTap/Plugins/Editor/CleverTapDependencies.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
<iosPods>
<iosPod name="CleverTap-iOS-SDK" version="5.2.1" minTargetSdk="9.0" />
<iosPod name="CleverTap-iOS-SDK" version="6.0.0" minTargetSdk="9.0" />
</iosPods>
</dependencies>
2 changes: 1 addition & 1 deletion CleverTap/Runtime/Constants/CleverTapVersion.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace CleverTapSDK.Constants {
internal static class CleverTapVersion {
internal const string CLEVERTAP_SDK_VERSION = "2.4.3";
internal const string CLEVERTAP_SDK_VERSION = "3.0.0";
}
}
2 changes: 1 addition & 1 deletion CleverTap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.clevertap.clevertap-sdk-unity",
"version": "2.4.2",
"version": "3.0.0",
"displayName": "CleverTap",
"description": "The CleverTap Unity SDK for App Analytics and Engagement.",
"documentationUrl": "https://www.clevertap.com/docs",
Expand Down
Binary file modified CleverTapSDK.unitypackage
Binary file not shown.
50 changes: 41 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,57 @@ To get started, sign up [here](https://clevertap.com/live-product-demo/).

## 🛠 Installation and Setup #

1. Import the CleverTapUnityPlugin.unitypackage into your Unity Project (`Assets` > `Import Package` > `Custom Package`) or manually Copy `Plugin/CleverTapUnity` and `Plugin/Plugins/Android` (or copy the files in `Plugin/Plugins/Android` to your existing `Assets/Plugins/Android` directory) into the Assets directory of your Unity Project.
You can install the CleverTap Unity SDK using the `.unitypackage` Unity package or as a local package through Unity Package Manager (UPM).

2. Create an empty game object (GameObject -> Create Empty) and rename it `CleverTapUnity`. Add `Assets/CleverTapUnity/CleverTapUnity-Scripts/CleverTapUnity.cs` as a component of the `CleverTapUnity GameObject`.
### Import the CleverTap Unity Package

| NOTE: To receive the SDK callbacks the name of the game object must be `CleverTapUnity` |
| --- |
1. Download the latest version of the CleverTap Unity package. Import the `.unitypackage` into your Unity Project. **Go to Assets** > **Import Package** > **Custom Package**.
2. Add the **PlayServiceResolver** and the **ExternalDependencyManager** folders. These folders will install the **EDM4U** plugin, which automatically adds all the Android and iOS dependencies when building your project.
3. Ensure that the scripts inside the `Editor` folder are added (`AndroidPostImport`, `CleverTapPostBuildProcessor.` and the other scripts). The `AndroidPostImport` script sets up `clevertap-android-wrapper` library for Android. `CleverTapPostBuildProcessor` helps iOS setup.

![alt text](example/images/unity_gameobj.jpg "unity game object")
### Import the CleverTap Unity Package as a Local Dependency

3. Select the `CleverTapUnity GameObject` you created in the Hierarchy pane and add your CleverTap settings inside the Inspector window. You must include your `CleverTap Account ID` and `CleverTap Account Token` from your [CleverTap Dashboard -> Settings](https://dashboard.clevertap.com/x/settings.html).
Clone the latest release version of CleverTap Unity SDK. The SDK can be imported as a local package through the Unity Package Manager.

4. Edit `Assets/CleverTapUnity/CleverTapUnity-Scripts/CleverTapUnity.cs` to add your calls to CleverTap SDK. See usage examples in [example/CleverTapUnity.cs](example/CleverTapUnity.cs). For more information check out our [documentation](https://developer.clevertap.com/docs "CleverTap Technical Documentation").
### Set Up the Unity SDK

CleverTap API can be accessed anywhere in your project by simply calling the static `CleverTap` class. _No_ need to create `GameObject` or attach _any_ script. The SDK handles the following:

- Instantiation of platform-specific binding (iOS, Android, Native)
- Creation of `GameObject`
- Script attachment.

You can view your `CleverTap Account ID` and `CleverTap Account Token` from the _CleverTap Dashboard -> Settings_.

```csharp
// Initialize CleverTap
CleverTap.LaunchWithCredentialsForRegion({YOUR_CLEVERTAP_ACCOUNT_ID}, {YOUR_CLEVERTAP_ACCOUNT_TOKEN}, {CLEVERTAP_ACCOUNT_REGION});
// Enable personalization
CleverTap.EnablePersonalization();
```

#### Callbacks

Add an event listener for a callback directly through the `CleverTap` static events.

```csharp
CleverTap.OnCleverTapDeepLinkCallback += YOUR_CALLBACK_METHOD;
CleverTap.OnCleverTapProfileInitializedCallback += YOUR_CALLBACK_METHOD;
CleverTap.OnCleverTapProfileUpdatesCallback += YOUR_CALLBACK_METHOD;
```

### iOS Instructions

iOS specific setup is described in the [iOS Instructions](/docs/Instructions-iOS.md)

### Android Instructions

Android specific setup is described in the [Android Instructions](/docs/Instructions-Android.md)

5. For more details around setup check out Android Specific Instructions [here](docs/Instructions-Android.md) and iOS Specific Instructions [here](docs/Instructions-iOS.md).

## 💻 Example Usage #

- [See the CleverTap Unity Usage Documentation](/docs/Usage.md)
- [See the included Example Project](/example) showing the integration of our Plugin

## 🆕 Changelog #

Expand Down
170 changes: 109 additions & 61 deletions docs/Instructions-Android.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,122 @@
## 👨‍💻 Android Specific Instructions:
- If you want to enable Push Notifications, be sure to add the Firebase Unity SDK to your app as described in the [Firebase Unity Setup Docs](https://firebase.google.com/docs/unity/setup)

> NOTE: On adding the Firebase Unity SDK it might cause your AndroidManifest.xml to be overriden. If that occurs, make sure to revert it your original manifest file.
- Add latest `Play Services Resolver` package from [here](https://github.com/googlesamples/unity-jar-resolver).

- Run `Assets` > `Play Services Resolver` > `Android Resolver` > `Resolve Client Jars` from the Unity menu bar to install the required google play services and android support library dependencies.

- Edit the `AndroidManifest.xml` file in `Assets/Plugins/Android` to add your Bundle Identifier, FCM Sender ID, CleverTap Account Id, CleverTap Token and Deep Link url scheme (if applicable):

```
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="YOUR_BUNDLE_IDENTIFIER" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal"> <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
```
```
<meta-data
android:name="FCM_SENDER_ID"
android:value="id:YOUR_FCM_SENDER_ID"/>
<meta-data
android:name="CLEVERTAP_ACCOUNT_ID"
android:value="Your CleverTap Account ID"/>
<meta-data
android:name="CLEVERTAP_TOKEN"
android:value="Your CleverTap Account Token"/>
```
```
<!-- Deep Links uncomment and replace YOUR_URL_SCHEME, if applicable, or remove if not supporting deep links-->
<!--
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="YOUR_URL_SCHEME" />
</intent-filter>
-->
```
- Add the following in the `AndroidManifest.xml` file, if not there already -
```

1. Go to **File** > **Build Settings** > **Android** > **Player Settings** > **Publishing Settings** > **Build**. Enable _.gradle templates_ and _custom AndroidManifest_. EDM4U populates the _Custom Main Gradle Template_ and _Gradle Properties Template_ with the required Android dependencies.

![Android Build Settings](/docs/images/android_settings.png "Android Build Settings")

2. Once you enable the custom Android Manifest, ensure to add additional configurations to enable Push Notifications and override the default `UnityActivity`. Add your Bundle Identifier, FCM Sender ID, CleverTap Account ID, CleverTap Token, and Deep Link URL scheme (if applicable):

```xml

<?xml version="1.0" encoding="utf-8"?>
<manifest package="YOUR_BUNDLE_IDENTIFIER"
xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="preferExternal"
android:versionCode="1"
android:versionName="1.0">

<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-feature android:glEsVersion="0x00020000" />

<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen.multitouch"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen.multitouch.distinct"
android:required="false" />

<application
android:debuggable="true"
android:icon="@drawable/app_icon"
android:isGame="true"
android:label="@string/app_name"
android:theme="@style/UnityThemeSelector">

<activity
android:name="com.clevertap.unity.CleverTapOverrideActivity"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="fullSensor">

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

<!-- Deep Links uncomment and replace YOUR_URL_SCHEME, if applicable, or remove if not supporting deep links-->
<!--
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="YOUR_URL_SCHEME" />
</intent-filter>
-->

<meta-data
android:name="unityplayer.UnityActivity"
android:value="true" />
</activity>

<service
android:name="com.clevertap.android.sdk.pushnotification.fcm.FcmMessageListenerService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

<service
android:name="com.clevertap.android.sdk.pushnotification.CTNotificationIntentService"
android:exported="false">
<intent-filter>
<action android:name="com.clevertap.PUSH_EVENT" />
</intent-filter>
</service>
```

- Add your `google-services.json` file to the Assets folder of the project.
<meta-data
android:name="FCM_SENDER_ID"
android:value="id:YOUR_FCM_SENDER_ID" />

- To enable A/B UI editor, edit `Assets/CleverTapUnity/CleverTapUnity-Scripts/CleverTapBinding.cs` and `CleverTapAPI.CallStatic("setUIEditorConnectionEnabled", true)` call just before getting the clevertap instance.
<meta-data
android:name="CLEVERTAP_ACCOUNT_ID"
android:value="Your CleverTap Account ID" />

**Code snippet for the same:**
<meta-data
android:name="CLEVERTAP_TOKEN"
android:value="Your CleverTap Account Token" />

</application>

</manifest>
```
public static AndroidJavaObject CleverTap {
get {
if (clevertap == null) {
AndroidJavaObject context = unityCurrentActivity.Call<AndroidJavaObject>("getApplicationContext");

//set the UI editor flag before getting the Clevertap instance, defaults to false.
CleverTapAPI.CallStatic("setUIEditorConnectionEnabled", true);

clevertap = CleverTapAPI.CallStatic<AndroidJavaObject>("getInstance", context);
}
return clevertap;
}
}

3. Add your `google-services.json` file to the project's **Assets** folder.
4. Build your app or Android project.

# Initialize CleverTap SDK

```csharp
// Initialize CleverTap
CleverTap.LaunchWithCredentialsForRegion({YOUR_CLEVERTAP_ACCOUNT_ID}, {YOUR_CLEVERTAP_ACCOUNT_TOKEN}, {CLEVERTAP_ACCOUNT_REGION});
// Enable personalization
CleverTap.EnablePersonalization();
```
- Build your app or Android project as usual.

74 changes: 74 additions & 0 deletions docs/Instructions-Android_v2.4.2_and_older.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
## 👨‍💻 Android Specific Instructions:
- If you want to enable Push Notifications, be sure to add the Firebase Unity SDK to your app as described in the [Firebase Unity Setup Docs](https://firebase.google.com/docs/unity/setup)

> NOTE: On adding the Firebase Unity SDK it might cause your AndroidManifest.xml to be overriden. If that occurs, make sure to revert it your original manifest file.
- Add latest `Play Services Resolver` package from [here](https://github.com/googlesamples/unity-jar-resolver).

- Run `Assets` > `Play Services Resolver` > `Android Resolver` > `Resolve Client Jars` from the Unity menu bar to install the required google play services and android support library dependencies.

- Edit the `AndroidManifest.xml` file in `Assets/Plugins/Android` to add your Bundle Identifier, FCM Sender ID, CleverTap Account Id, CleverTap Token and Deep Link url scheme (if applicable):

```
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="YOUR_BUNDLE_IDENTIFIER" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal"> <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
```
```
<meta-data
android:name="FCM_SENDER_ID"
android:value="id:YOUR_FCM_SENDER_ID"/>
<meta-data
android:name="CLEVERTAP_ACCOUNT_ID"
android:value="Your CleverTap Account ID"/>
<meta-data
android:name="CLEVERTAP_TOKEN"
android:value="Your CleverTap Account Token"/>
```
```
<!-- Deep Links uncomment and replace YOUR_URL_SCHEME, if applicable, or remove if not supporting deep links-->
<!--
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="YOUR_URL_SCHEME" />
</intent-filter>
-->
```
- Add the following in the `AndroidManifest.xml` file, if not there already -
```
<service
android:name="com.clevertap.android.sdk.pushnotification.fcm.FcmMessageListenerService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
```
- Add your `google-services.json` file to the Assets folder of the project.
- To enable A/B UI editor, edit `Assets/CleverTapUnity/CleverTapUnity-Scripts/CleverTapBinding.cs` and `CleverTapAPI.CallStatic("setUIEditorConnectionEnabled", true)` call just before getting the clevertap instance.
**Code snippet for the same:**
```
public static AndroidJavaObject CleverTap {
get {
if (clevertap == null) {
AndroidJavaObject context = unityCurrentActivity.Call<AndroidJavaObject>("getApplicationContext");

//set the UI editor flag before getting the Clevertap instance, defaults to false.
CleverTapAPI.CallStatic("setUIEditorConnectionEnabled", true);

clevertap = CleverTapAPI.CallStatic<AndroidJavaObject>("getInstance", context);
}
return clevertap;
}
}
```
- Build your app or Android project as usual.
Loading

0 comments on commit d711384

Please sign in to comment.