Skip to content

Commit

Permalink
Merge pull request #38 from MartinGonzalez/fix/no-appboy-methods-on-a…
Browse files Browse the repository at this point in the history
…ctivity

Create and call InAppMessageUtils java class instead of calling Appbo…
  • Loading branch information
Bucimis authored May 7, 2018
2 parents 81e1a39 + 6c41fff commit cc71c2c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 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
20 changes: 17 additions & 3 deletions Assets/Plugins/Appboy/AppboyBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ public static void DisableSDK() {
#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 @@ -366,6 +367,16 @@ public static AndroidJavaObject Appboy {
return appboy;
}
}

public static AndroidJavaObject InAppMessageUtils {
get {
if (inAppMessageUtils == null) {
inAppMessageUtils = new AndroidJavaClass("com.appboy.unity.utils.InAppMessageUtils");
}
return inAppMessageUtils;
}
}

#endregion

private static AndroidJavaObject GetCurrentUser() {
Expand Down Expand Up @@ -692,15 +703,18 @@ public static void RequestFeedRefreshFromCache() {
}

public static void LogInAppMessageClicked(string inAppMessageJSONString) {
AppboyUnityActivity.Call("logInAppMessageClick", new object[] { inAppMessageJSONString });
var inAppMessage = InAppMessageUtils.CallStatic<AndroidJavaObject>("inAppMessageFromString", appboyUnityActivity, inAppMessageJSONString);
InAppMessageUtils.CallStatic("logInAppMessageClick", inAppMessage);
}

public static void LogInAppMessageImpression(string inAppMessageJSONString) {
AppboyUnityActivity.Call("logInAppMessageImpression", new object[] { inAppMessageJSONString });
var inAppMessage = InAppMessageUtils.CallStatic<AndroidJavaObject>("inAppMessageFromString", appboyUnityActivity, inAppMessageJSONString);
InAppMessageUtils.CallStatic("logInAppMessageImpression", inAppMessage);
}

public static void LogInAppMessageButtonClicked(string inAppMessageJSONString, int buttonID) {
AppboyUnityActivity.Call("logInAppMessageButtonClick", new object[] { inAppMessageJSONString, buttonID });
var inAppMessage = InAppMessageUtils.CallStatic<AndroidJavaObject>("inAppMessageFromString", appboyUnityActivity, inAppMessageJSONString);
InAppMessageUtils.CallStatic("logInAppMessageButtonClick", inAppMessage, buttonID);
}

public static void LogFeedDisplayed() {
Expand Down

0 comments on commit cc71c2c

Please sign in to comment.