Skip to content

Commit

Permalink
Create and call InAppMessageUtils java class instead of calling Appbo…
Browse files Browse the repository at this point in the history
…y methods in the Main Activity class. Update AndroidManifest.xml using AppboyUnityPlayerActivity instead of AppboyUnityPlayerNativeActivity
  • Loading branch information
Martin Gonzalez committed Apr 28, 2018
1 parent fe6ed52 commit 83bd90b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Assets/Plugins/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
android:debuggable="true">
<amazon:enable-feature android:name="com.amazon.device.messaging" android:required="false"/>

<activity android:name="com.appboy.unity.AppboyUnityPlayerNativeActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="sensor">
<activity android:name="com.appboy.unity.AppboyUnityPlayerActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="sensor">
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
<intent-filter>
Expand Down
Binary file modified Assets/Plugins/Android/libs/appboy-unity.aar
Binary file not shown.
23 changes: 18 additions & 5 deletions Assets/Plugins/Appboy/AppboyBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ public static void LogFeedbackDisplayed() {
#elif UNITY_ANDROID
private static AndroidJavaObject appboyUnityActivity;
private static AndroidJavaObject appboy;
private static AndroidJavaObject inAppMessageUtils;

void Start() {
Debug.Log("Starting Appboy binding for Android clients.");
Expand Down Expand Up @@ -355,6 +356,18 @@ public static AndroidJavaObject Appboy {
return appboy;
}
}

public static AndroidJavaObject InAppMessageUtils {
get {
if (inAppMessageUtils != null) return inAppMessageUtils;

inAppMessageUtils = new AndroidJavaClass("com.appboy.unity.utils.InAppMessageUtils");
inAppMessageUtils.CallStatic("setContext", AppboyUnityActivity);

return inAppMessageUtils;
}
}

#endregion

private static AndroidJavaObject GetCurrentUser() {
Expand Down Expand Up @@ -681,25 +694,25 @@ public static void RequestFeedRefreshFromCache() {
}

public static void LogInAppMessageClicked(string inAppMessageJSONString) {
AppboyUnityActivity.Call("logInAppMessageClick", new object[] { inAppMessageJSONString });
InAppMessageUtils.CallStatic("logInAppMessageClick", new object[] { inAppMessageJSONString });
}

public static void LogInAppMessageImpression(string inAppMessageJSONString) {
AppboyUnityActivity.Call("logInAppMessageImpression", new object[] { inAppMessageJSONString });
InAppMessageUtils.CallStatic("logInAppMessageImpression", new object[] { inAppMessageJSONString });
}

public static void LogInAppMessageButtonClicked(string inAppMessageJSONString, int buttonID) {
AppboyUnityActivity.Call("logInAppMessageButtonClick", new object[] { inAppMessageJSONString, buttonID });
InAppMessageUtils.CallStatic("logInAppMessageButtonClick", new object[] { inAppMessageJSONString, buttonID });
}

[System.Obsolete("LogSlideupClicked is deprecated, please use LogInAppMessageClicked instead.")]
public static void LogSlideupClicked(string slideupJSONString) {
AppboyUnityActivity.Call("logInAppMessageClick", new object[] { slideupJSONString });
InAppMessageUtils.CallStatic("logInAppMessageClick", new object[] { slideupJSONString });
}

[System.Obsolete("LogSlideupImpression is deprecated, please use LogInAppMessageImpression instead.")]
public static void LogSlideupImpression(string slideupJSONString) {
AppboyUnityActivity.Call("logInAppMessageImpression", new object[] { slideupJSONString });
InAppMessageUtils.CallStatic("logInAppMessageImpression", new object[] { slideupJSONString });
}

public static void LogFeedDisplayed() {
Expand Down

0 comments on commit 83bd90b

Please sign in to comment.