Skip to content

Commit 610afd1

Browse files
nzagorchevvasct
andauthored
Release 7.0.0 (#151)
* Update CleverTap package (#143) * Update import package script * Update CleverTap package * Use EDM4U (#144) * Import EDM4U * Add iOS dependencies * Remove unused android dependencies * Remove xcframeworks * Update project version * Update build * Update package (#145) * Update iOS CleverTap initialization (#146) * Update iOS CleverTap initialization * Update package * Make LP Android plugin a library module (#147) Remove LP Android aar build and instead add it as a source module to the unityLibrary Android module. Make it depend on the clevertap library module so its methods can be used in LP Unity plugin. * Set the CT instance created from native LP Android to CT Unity (#148) * Set the CT instance created from native LP Android to CT Unity * Init CleverTapUnityPlugin on UnityBridge.start * Add gcm_defaultSenderId to the generated google services xml file This is needed for CT push notifications to work if the client has not integrated Firebase Unity package in their project * Remove application definition from the manifest * Update unitypackage * Add documentation Add Android instructions, Android migration to v7 and CleverTap integration docs * Set LP Android version to 7.6.3 * Update packages (#149) * Update leanplum package (#150) * Update Leanplum package * Update iOS SDK version * Update version and package * Update docs --------- Co-authored-by: Vassil Angelov <148857285+vasct@users.noreply.github.com>
1 parent 7e1fb10 commit 610afd1

File tree

1,005 files changed

+19023
-91862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,005 files changed

+19023
-91862
lines changed

Docs/Android-Instructions.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Leanplum Unity Android Integration Instructions
2+
After you have imported the Leanplum SDK unity package do the following steps to complete the integration for the Android platform:
3+
1. Enable custom main manifest file in Unity. In the Unity Editor, navigate to `Build Settings - Player Settings - Publishing Settings` and enable `Custom Main Manifest`.
4+
2. Edit `Assets/Plugins/Android/AndroidManifest.xml` to set the application class. You can use the provided `LeanplumApplication` class, extend it with your own class, or have a completely separate class, which calls the appropriate Leanplum API.
5+
* Add the application class to the manifest file:
6+
```diff
7+
<manifest
8+
xmlns:android="http://schemas.android.com/apk/res/android"
9+
xmlns:tools="http://schemas.android.com/tools">
10+
- <application>
11+
+ <application android:name="com.leanplum.LeanplumUnityApplication">
12+
<activity android:name="com.unity3d.player.UnityPlayerActivity"
13+
android:theme="@style/UnityThemeSelector">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
19+
</activity>
20+
</application>
21+
</manifest>
22+
```
23+
* If you are using a custom application class extend `LeanplumApplication`:
24+
```java
25+
public class YourApplication extends LeanplumUnityApplication {
26+
...
27+
}
28+
```
29+
or call `LeanplumUnity.initialize(this)` in the `onCreate` method:
30+
```java
31+
public class YourApplication extends Application {
32+
33+
@Override
34+
public void onCreate() {
35+
super.onCreate();
36+
LeanplumUnity.initialize(this);
37+
}
38+
}
39+
```
40+
## Include Optional Leanplum Features
41+
1. Enable main gradle template file in Unity. In the Unity Editor, navigate to `Build Settings - Player Settings - Publishing Settings` and enable `Custom Main Gradle Template`.
42+
2. Edit `Assets/Plugins/Android/mainTemplate.gradle` to include only the desired optional features:
43+
```groovy
44+
dependencies {
45+
// Push
46+
implementation "com.leanplum:leanplum-push:${LP_VERSION}"
47+
48+
// FCM
49+
implementation "com.leanplum:leanplum-fcm:${LP_VERSION}"
50+
implementation 'com.google.firebase:firebase-messaging:22.0.0'
51+
52+
// HMS
53+
implementation "com.leanplum:leanplum-hms:${LP_VERSION}"
54+
55+
// Location
56+
implementation "com.leanplum:leanplum-location:${LP_VERSION}"
57+
implementation "com.google.android.gms:play-services-location:18.0.0"
58+
}
59+
```
60+
3. Use the same version for the optional features as the Leanplum version in `Assets/Plugins/Android/leanplum-unity-wrapper.androidlib/build.gradle`
61+
```groovy
62+
def LP_VERSION = "X.X.X"
63+
```
64+
4. If you are using FCM, download `google-service.json` file and put it into root of `Assets` folder. When Android project is exported it will automatically parse the file.
65+
## CleverTap Integration
66+
1. Edit `Assets/Plugins/Android/AndroidManifest.xml` to set the launcher activity to the CleverTap class:
67+
```diff
68+
<manifest
69+
xmlns:android="http://schemas.android.com/apk/res/android"
70+
xmlns:tools="http://schemas.android.com/tools">
71+
<application>
72+
<application android:name="com.leanplum.LeanplumUnityApplication">
73+
- <activity android:name="com.unity3d.player.UnityPlayerActivity"
74+
+ <activity android:name="com.clevertap.unity.CleverTapOverrideActivity"
75+
android:theme="@style/UnityThemeSelector">
76+
<intent-filter>
77+
<action android:name="android.intent.action.MAIN" />
78+
<category android:name="android.intent.category.LAUNCHER" />
79+
</intent-filter>
80+
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
81+
</activity>
82+
</application>
83+
</manifest>
84+
```
85+
2. Use CleverTap Unity API after `Leanplum.CleverTapInstanceReady` event is received:
86+
```csharp
87+
Leanplum.CleverTapInstanceReady += () =>
88+
{
89+
// CleverTap is ready to use
90+
CleverTap.CreateNotificationChannel(
91+
"YourChannelId",
92+
"Your Channel Name",
93+
"Your Channel Description",
94+
5,
95+
true);
96+
};
97+
```
98+
3. Do not use CleverTapSettings from the Unity editor and do not add CleverTap account data in the AndroidManifest.xml file, Leanplum will apply the correct values automatically.
99+
4. See how to enable the optional CleverTap features [here](CleverTap-Optional-Features.md)
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Enable CleverTap optional features
2+
## Audio and video content within in-app notifications
3+
Add the following dependencies to `Assets/Plugins/Android/mainTemplate.gradle`:
4+
```diff
5+
dependencies {
6+
//...
7+
+ // ExoPlayer for CT
8+
+ implementation 'androidx.media3:media3-exoplayer:1.1.1'
9+
+ implementation 'androidx.media3:media3-exoplayer-hls:1.1.1'
10+
+ implementation 'androidx.media3:media3-ui:1.1.1'
11+
//...
12+
}
13+
```
14+
## Notification Inbox
15+
Add the following dependencies to `Assets/Plugins/Android/mainTemplate.gradle`:
16+
```diff
17+
dependencies {
18+
//...
19+
+ implementation("com.github.bumptech.glide:glide:4.12.0")
20+
+ implementation("com.google.android.material:material:1.12.0")
21+
+ implementation("androidx.fragment:fragment:1.5.4")
22+
+ implementation("androidx.appcompat:appcompat:1.7.0")
23+
+ implementation("androidx.recyclerview:recyclerview:1.3.2")
24+
+ implementation("androidx.viewpager:viewpager:1.0.0")
25+
//...
26+
}
27+
```
28+
## RenderMax
29+
Add the following dependency to `Assets/Plugins/Android/mainTemplate.gradle`:
30+
```diff
31+
dependencies {
32+
//...
33+
+ implementation "com.clevertap.android:clevertap-rendermax-sdk:1.0.3"
34+
//...
35+
}
36+
```
37+
## Custom Code Templates
38+
1. Follow the instructions in the CleverTap documentation [here](https://github.com/CleverTap/clevertap-unity-sdk/blob/master/docs/CustomCodeTemplates.md) to define your templates.
39+
2. Register the custom code delegates in `Leanplum.CleverTapInstanceReady`:
40+
```csharp
41+
private void InitLeanplum()
42+
{
43+
Leanplum.CleverTapInstanceReady += () =>
44+
{
45+
// Call SyncCustomTemplates once to sync the templates to the dashboard. Make sure to call it in a debug build.
46+
// CleverTap.SyncCustomTemplates();
47+
CleverTap.OnCustomTemplatePresent += CleverTapCustomTemplatePresent;
48+
CleverTap.OnCustomFunctionPresent += CleverTapCustomFunctionPresent;
49+
CleverTap.OnCustomTemplateClose += CleverTapCustomTemplateClose;
50+
};
51+
52+
}
53+
54+
private void CleverTapCustomTemplatePresent(CleverTapTemplateContext context)
55+
{
56+
// show the UI for the template, be sure to keep the context as long as the template UI
57+
// is being displayed so that context.setDismissed() can be called when the UI is closed.
58+
ShowTemplateUi(context);
59+
// call customTemplateSetPresented when the UI has become visible to the user
60+
context.SetPresented();
61+
}
62+
63+
private void CleverTapCustomFunctionPresent(CleverTapTemplateContext context)
64+
{
65+
// show the UI for the template, be sure to keep the context as long as the template UI
66+
// is being displayed so that context.setDismissed() can be called when the UI is closed.
67+
ShowTemplateUi(context);
68+
// call customTemplateSetPresented when the UI has become visible to the user
69+
context.SetPresented();
70+
}
71+
72+
private void CleverTapCustomTemplateClose(CleverTapTemplateContext context)
73+
{
74+
// close the corresponding UI before calling customTemplateSetDismissed
75+
context.SetDismissed();
76+
}
77+
```
78+
## Push Templates
79+
1. Add the following dependency to `Assets/Plugins/Android/mainTemplate.gradle`:
80+
```diff
81+
dependencies {
82+
//...
83+
+ implementation 'com.clevertap.android:push-templates:1.2.4'
84+
}
85+
```
86+
2. Create a custom Application Java class in `Assets/Plugins/Android/` with the push templates initialization call:
87+
```java
88+
package com.example.app;
89+
90+
import com.clevertap.android.pushtemplates.PushTemplateNotificationHandler;
91+
import com.clevertap.android.sdk.CleverTapAPI;
92+
import com.leanplum.LeanplumUnityApplication;
93+
94+
public class ExampleApplication extends LeanplumUnityApplication {
95+
96+
@Override
97+
public void onCreate() {
98+
CleverTapAPI.setNotificationHandler(new PushTemplateNotificationHandler());
99+
super.onCreate();
100+
}
101+
}
102+
```
103+
3. Set your custom Application class in the AndroidManifest.xml:
104+
```diff
105+
<manifest
106+
xmlns:android="http://schemas.android.com/apk/res/android"
107+
xmlns:tools="http://schemas.android.com/tools">
108+
- <application android:name="com.leanplum.LeanplumUnityApplication">
109+
+ <application android:name="com.example.app.ExampleApplication">
110+
<activity android:name="com.unity3d.player.UnityPlayerActivity"
111+
android:theme="@style/UnityThemeSelector">
112+
<intent-filter>
113+
<action android:name="android.intent.action.MAIN" />
114+
<category android:name="android.intent.category.LAUNCHER" />
115+
</intent-filter>
116+
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
117+
</activity>
118+
</application>
119+
</manifest>
120+
```

Docs/Migration-V7.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Update to Leanplum-Unity-SDK 7.0.0
2+
## Android Setup
3+
Leanplum SDK 7.0.0 has structural changes to its Android project setup, which enable more flexible ways of integrating the SDK and improve the integration with the CleverTap Unity SDK. Namely the leanplum-wrapper is now included as a module in the android project generated by Unity, instead of it being supplied as an .aar library. Due to some limitations of how Unity packages are distributed, there are a few manual changes that need to be made when updating from a previous version of the SDK:
4+
### Leanplum Update
5+
6+
1. Import the updated Leanplum Unity package to your project.
7+
8+
2. Edit `Assets/Plugins/Android/mainTemplate.gradle` with the following changes:
9+
* Remove Leanplum Core and CleverTap dependencies. They will be automatically provided in the leanplum-wrapper module.
10+
```diff
11+
-def CT_SDK_VERSION = "6.1.1"
12+
```
13+
```diff
14+
- implementation "com.leanplum:leanplum-core:${LEANPLUM_SDK_VERSION}"
15+
- implementation "com.clevertap.android:clevertap-android-sdk:${CT_SDK_VERSION}"
16+
- //implementation(name: "com.leanplum.unity-wrapper-${LEANPLUM_SDK_VERSION}", ext:'aar')
17+
- //implementation project(':android-unity-wrapper')
18+
```
19+
* If you are using other leanplum libraries like `:push`, `:fcm`, `:location` or `:hms` update their version to the one in `Assets/Plugins/Android/leanplum-unity-wrapper.androidlib/build.gradle`
20+
```groovy
21+
def LP_VERSION = "X.X.X"
22+
```
23+
```diff
24+
Assets/Plugins/Android/mainTemplate.gradle
25+
-def LEANPLUM_SDK_VERSION = "7.4.1"
26+
+def LEANPLUM_SDK_VERSION = "X.X.X"
27+
```
28+
* Remove mi-push libraries. They are not longer supported
29+
```diff
30+
- // Uncomment for MiPush. Note that leanplum-mipush package is deprecated. MiPush will be used through CleverTap SDK.
31+
- // implementation "com.leanplum:leanplum-mipush:${LEANPLUM_SDK_VERSION}"
32+
```
33+
1. Enable custom main manifest file in Unity. In the Unity Editor, navigate to `Build Settings - Player Settings - Publishing Settings` and enable `Custom Main Manifest`.
34+
2. Edit `Assets/Plugins/Android/AndroidManifest.xml` to set the application class. You can use the provided `LeanplumApplication` class, extend it with your own class, or have a completely separate class, which calls the appropriate Leanplum API.
35+
* Add the application class to the manifest file:
36+
```diff
37+
<manifest
38+
xmlns:android="http://schemas.android.com/apk/res/android"
39+
xmlns:tools="http://schemas.android.com/tools">
40+
- <application>
41+
+ <application android:name="com.leanplum.LeanplumUnityApplication">
42+
<activity android:name="com.unity3d.player.UnityPlayerActivity"
43+
android:theme="@style/UnityThemeSelector">
44+
<intent-filter>
45+
<action android:name="android.intent.action.MAIN" />
46+
<category android:name="android.intent.category.LAUNCHER" />
47+
</intent-filter>
48+
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
49+
</activity>
50+
</application>
51+
</manifest>
52+
```
53+
* If you are using a custom application class extend `LeanplumApplication`:
54+
```java
55+
public class YourApplication extends LeanplumUnityApplication {
56+
...
57+
}
58+
```
59+
or call `LeanplumUnity.initialize(this)` in the `onCreate` method:
60+
```java
61+
public class YourApplication extends Application {
62+
63+
@Override
64+
public void onCreate() {
65+
super.onCreate();
66+
LeanplumUnity.initialize(this);
67+
}
68+
}
69+
```
70+
### CleverTap Integration Update
71+
1. Edit `Assets/Plugins/Android/AndroidManifest.xml` to set the launcher activity to the CleverTap class:
72+
```diff
73+
<manifest
74+
xmlns:android="http://schemas.android.com/apk/res/android"
75+
xmlns:tools="http://schemas.android.com/tools">
76+
<application>
77+
<application android:name="com.leanplum.LeanplumUnityApplication">
78+
- <activity android:name="com.unity3d.player.UnityPlayerActivity"
79+
+ <activity android:name="com.clevertap.unity.CleverTapOverrideActivity"
80+
android:theme="@style/UnityThemeSelector">
81+
<intent-filter>
82+
<action android:name="android.intent.action.MAIN" />
83+
<category android:name="android.intent.category.LAUNCHER" />
84+
</intent-filter>
85+
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
86+
</activity>
87+
</application>
88+
</manifest>
89+
```
90+
2. Use CleverTap Unity API after `Leanplum.CleverTapInstanceReady` event is received:
91+
```csharp
92+
Leanplum.CleverTapInstanceReady += () =>
93+
{
94+
// CleverTap is ready to use
95+
CleverTap.CreateNotificationChannel(
96+
"YourChannelId",
97+
"Your Channel Name",
98+
"Your Channel Description",
99+
5,
100+
true);
101+
};
102+
```
103+
3. Do not use CleverTapSettings from the Unity editor and do not add CleverTap account data in the AndroidManifest.xml file, Leanplum will apply the correct values automatically.
104+
4. See how to enable the optional CleverTap features [here](CleverTap-Optional-Features.md)
105+
106+
## iOS Setup
107+
Leanplum SDK 7.0.0 has iOS integration changes. The Leanplum iOS SDK and its dependencies CleverTap iOS SDK and SDWebImage are no longer included as xcframeworks in the Plugins/iOS folder. The dependencies are now resolved using the External Dependency Manager for Unity.
108+
109+
### Leanplum Update
110+
1. Dependencies
111+
Delete the xcframeworks from Plugins/iOS folder if they exist.
112+
The required dependencies are installed using CocoaPods and the [EDM4U](https://github.com/googlesamples/unity-jar-resolver) plugin. Set up EDM4U plugin to install CocoaPods automatically. Go to Assets > External Dependency Manager > iOS Resolver > Settings. Check Podfile generate and choose Cocoapods Integration - Add Cocoapods to the Xcode workspace.
113+
Alternatively, manually install pods by running pod install in the exported XCode project. Ensure to start .xcworkspace to build the app with dependencies.
114+
115+
2. `LeanplumUnityAppController`
116+
Leanplum adds a subclass of the `UnityAppController`. It sets up `UNUserNotificationCenter`. It is primarily used for CleverTap Unity migration.
117+
If you use your own `UnityAppController` override, inherit from the `CleverTapUnityAppController` or call the CleverTap methods. If you use your own one, you can disable the `LeanplumUnityAppController` by setting `LP_NO_APP_CONTROLLER_SUBCLASS` preprocessor macro.
118+
119+
3. Post Process Build Script
120+
Ensure the `LeanplumApplePostProcessor` script is updated when you update the SDK and import the assets. The build script _no_ longer adds the xcframeworks. It updates `GCC_PREPROCESSOR_DEFINITIONS` macros.
121+
122+
4. Do _not_ use CleverTapSettings from the Unity editor and do not add CleverTap account data in the Info.plist file, Leanplum will apply the correct values automatically.
123+
124+
## CleverTap Usage
125+
It is _no_ longer required to have a "CleverTapUnity" `GameObject`. Remove the object since the CleverTap SDK will create the required game objects automatically.
126+
You should now use the `CleverTap` static interface (_not_ `CleverTapBinding`). CleverTap callbacks can be registered from any object now (_no_ longer required to be in CleverTapUnity.cs).
127+
128+
If you want to do any CleverTap configurations or call CleverTap SDK directly, you need to do that inside the `CleverTapReady` callback. This ensures CleverTap is initialized and ready:
129+
130+
```c-sharp
131+
Leanplum.CleverTapInstanceReady += () =>
132+
{
133+
// Record basic event with no properties
134+
CleverTap.RecordEvent("testEvent");
135+
};
136+
```
137+

Leanplum-Android-SDK-Unity/.gitignore

Lines changed: 0 additions & 11 deletions
This file was deleted.
-564 Bytes
Binary file not shown.
-116 KB
Binary file not shown.

Leanplum-Android-SDK-Unity/.idea/gradle.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

Leanplum-Android-SDK-Unity/.idea/misc.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)