Skip to content

Commit

Permalink
Updating Unity plugins for version 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
radixdev committed Feb 3, 2020
1 parent cce7c33 commit 47e7d57
Show file tree
Hide file tree
Showing 19 changed files with 302 additions and 126 deletions.
74 changes: 62 additions & 12 deletions Assets/Editor/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,72 @@

namespace Appboy.Editor {
public static class Build {
private static string[] AssetPathNames = {
"Assets/Plugins/Android",
"Assets/Plugins/Appboy",
"Assets/Plugins/iOS"
};

public static void ExportPackage() {
Debug.Log("Exporting Appboy Unity Package...");
System.IO.Directory.CreateDirectory("unity-package");
public static void ExportAllPackages() {
// Create all the unity packages in one go
ExportPackage_NonJetified_AllIosDeps();
ExportPackage_NonJetified_NoIosDeps();
ExportPackage_Jetified_AllIosDeps();
ExportPackage_Jetified_NoIosDeps();
}

private static void ExportPackage_NonJetified_AllIosDeps() {
Debug.Log("Running ExportPackage_NonJetified_AllIosDeps");

string[] AssetPathNames = {
"Assets/Plugins/Android/appboy.aar",
"Assets/Plugins/Android/appboy-ui.aar",
"Assets/Plugins/Android/appboy-unity.aar",
"Assets/Plugins/Appboy",
"Assets/Plugins/iOS"
};
AssetDatabase.ExportPackage(AssetPathNames, "unity-package/Appboy.unitypackage", ExportPackageOptions.Recurse);
}

public static void ExportPackageWithoutDependencies() {
Debug.Log("Exporting Appboy Unity Package without dependencies...");
System.IO.Directory.CreateDirectory("unity-package");
private static void ExportPackage_NonJetified_NoIosDeps() {
Debug.Log("Running ExportPackage_NonJetified_NoIosDeps");

string[] AssetPathNames = {
"Assets/Plugins/Android/appboy.aar",
"Assets/Plugins/Android/appboy-ui.aar",
"Assets/Plugins/Android/appboy-unity.aar",
"Assets/Plugins/Appboy",
"Assets/Plugins/iOS/AppboyAppDelegate.mm",
"Assets/Plugins/iOS/AppboyBinding.m",
"Assets/Plugins/iOS/AppboyUnityManager.h",
"Assets/Plugins/iOS/AppboyUnityManager.mm",
"Assets/Plugins/iOS/Appboy_iOS_SDK.framework"
};
AssetDatabase.ExportPackage(AssetPathNames, "unity-package/Appboy-nodeps.unitypackage", ExportPackageOptions.Recurse);
}

private static void ExportPackage_Jetified_AllIosDeps() {
Debug.Log("Running ExportPackage_Jetified_AllIosDeps");

string[] AssetPathNames = {
"Assets/Plugins/Android/appboy-jetified.aar",
"Assets/Plugins/Android/appboy-ui-jetified.aar",
"Assets/Plugins/Android/appboy-unity-jetified.aar",
"Assets/Plugins/Appboy",
"Assets/Plugins/iOS"
};
AssetDatabase.ExportPackage(AssetPathNames, "unity-package/Appboy-jetified.unitypackage", ExportPackageOptions.Recurse);
}

private static void ExportPackage_Jetified_NoIosDeps() {
Debug.Log("Running ExportPackage_Jetified_NoIosDeps");

string[] AssetPathNames = {
"Assets/Plugins/Android/appboy-jetified.aar",
"Assets/Plugins/Android/appboy-ui-jetified.aar",
"Assets/Plugins/Android/appboy-unity-jetified.aar",
"Assets/Plugins/Appboy",
"Assets/Plugins/iOS/AppboyAppDelegate.mm",
"Assets/Plugins/iOS/AppboyBinding.m",
"Assets/Plugins/iOS/AppboyUnityManager.h",
"Assets/Plugins/iOS/AppboyUnityManager.mm",
"Assets/Plugins/iOS/Appboy_iOS_SDK.framework"
};
AssetDatabase.ExportPackage(AssetPathNames, "unity-package/Appboy-jetified-nodeps.unitypackage", ExportPackageOptions.Recurse);
}
}
}
53 changes: 0 additions & 53 deletions Assets/Plugins/Android/AndroidManifest.xml

This file was deleted.

Binary file added Assets/Plugins/Android/appboy-jetified.aar
Binary file not shown.
Binary file added Assets/Plugins/Android/appboy-ui-jetified.aar
Binary file not shown.
Binary file added Assets/Plugins/Android/appboy-ui.aar
Binary file not shown.
Binary file added Assets/Plugins/Android/appboy-unity-jetified.aar
Binary file not shown.
Binary file added Assets/Plugins/Android/appboy-unity.aar
Binary file not shown.
Binary file added Assets/Plugins/Android/appboy.aar
Binary file not shown.
Binary file removed Assets/Plugins/Android/libs/appboy-ui.aar
Binary file not shown.
Binary file removed Assets/Plugins/Android/libs/appboy-unity.aar
Binary file not shown.
Binary file removed Assets/Plugins/Android/libs/appboy.aar
Binary file not shown.
35 changes: 0 additions & 35 deletions Assets/Plugins/Android/res/values/appboy.xml

This file was deleted.

50 changes: 50 additions & 0 deletions Assets/Plugins/Appboy/AppboyBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ void Start() {
[System.Runtime.InteropServices.DllImport("__Internal")]
private static extern void _setAttributionData(string network, string campaign, string adgroup, string creative);

[System.Runtime.InteropServices.DllImport("__Internal")]
private static extern void _requestGeofences(decimal latitude, decimal longitude);

[System.Runtime.InteropServices.DllImport("__Internal")]
private static extern void _requestImmediateDataFlush();

public static void LogCustomEvent(string eventName) {
_logCustomEvent(eventName, null);
}
Expand Down Expand Up @@ -320,6 +326,7 @@ public static void LogCardClicked(string cardJSONString) {
public static void RequestFeedRefresh() {
_requestFeedRefresh();
}

public static void RequestFeedRefreshFromCache() {
_requestFeedRefreshFromCache();
}
Expand All @@ -339,6 +346,7 @@ public static void LogContentCardClicked(string cardJSONString) {
public static void RequestContentCardsRefresh() {
_requestContentCardsRefresh();
}

public static void RequestContentCardsRefreshFromCache() {
_requestContentCardsRefreshFromCache();
}
Expand Down Expand Up @@ -372,6 +380,24 @@ public static void RequestLocationInitialization() {
// no-op
}

/// <summary>
/// Requests a refresh of Braze Geofences for the specified GPS coordinate.
/// </summary>
/// <param name='latitude'>
/// A valid GPS latitude in range (-90, 90).
/// </param>
/// <param name='longitude'>
/// A valid GPS longitude in range (-180, 180).
/// </param>
/// </summary>
public static void RequestGeofences(decimal latitude, decimal longitude) {
_requestGeofences(latitude, longitude);
}

public static void RequestImmediateDataFlush() {
_requestImmediateDataFlush();
}

#elif UNITY_ANDROID
private static AndroidJavaObject appboyUnityActivity;
private static AndroidJavaObject inAppMessageUtils;
Expand Down Expand Up @@ -809,6 +835,24 @@ public static void RequestLocationInitialization() {
AppboyLocationService.CallStatic("requestInitialization", appboyUnityActivity);
}

/// <summary>
/// Requests a refresh of Braze Geofences for the specified GPS coordinate.
/// </summary>
/// <param name='latitude'>
/// A valid GPS latitude in range (-90, 90).
/// </param>
/// <param name='longitude'>
/// A valid GPS longitude in range (-180, 180).
/// </param>
/// </summary>
public static void RequestGeofences(decimal latitude, decimal longitude) {
Appboy.Call("requestGeofences", latitude, longitude);
}

public static void RequestImmediateDataFlush() {
Appboy.Call("requestImmediateDataFlush");
}

#else

// Empty implementations of the API, in case the application is being compiled for a platform other than iOS or Android.
Expand Down Expand Up @@ -964,6 +1008,12 @@ public static void SetAttributionData(string network, string campaign, string ad

public static void RequestLocationInitialization() {
}

public static void RequestGeofences(decimal latitude, decimal longitude) {
}

public static void RequestImmediateDataFlush() {
}
#endif
}
}
9 changes: 9 additions & 0 deletions Assets/Plugins/iOS/AppboyBinding.m
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,12 @@ void _disableSDK() {
void _setAttributionData(const char* network, const char* campaign,const char* adgroup, const char* creative) {
[[AppboyUnityManager sharedInstance] setAttributionData:GetStringParam(network) campaign:GetStringParam(campaign) adgroup:GetStringParam(adgroup) creative:GetStringParam(creative)];
}

void _requestGeofences(int latitude, int longitude) {
[[Appboy sharedInstance] requestGeofencesWithLongitude:longitude
latitude:latitude];
}

void _requestImmediateDataFlush() {
[[Appboy sharedInstance] flushDataAndProcessRequestQueue];
}
2 changes: 2 additions & 0 deletions Assets/Plugins/iOS/AppboyUnityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ static NSString *const ABKUnityHandleInAppMessageDisplayKey = @"DisplayInAppMess
- (void) logContentCardImpression:(NSString *)cardJSONString;
- (void) logContentCardClicked:(NSString *)cardJSONString;
- (void) displayNextInAppMessageWithDelegate:(BOOL)withDelegate;
- (void) requestGeofences;
- (void) requestImmediateDataFlush;
+ (void) wipeDataAndDisableForAppRun;
+ (void) disableSDK;
+ (void) requestEnableSDKOnNextAppRun;
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## 2.0.0

##### ⚠ Breaking
- The structure of the Android plugin (i.e. found under `Assets/Plugins/Android/`) has been changed to only include AAR artifacts. All other folders have been removed.
- Additionally, depending on the `.unitypackage` chosen, you can import jetified Braze AAR artifacts. These artifacts were transformed using the [`jetifier`](https://developer.android.com/studio/command-line/jetifier) tool to be compatible with `androidX` support libraries instead of the `v4` support libraries. This is particularly relevant if you wish to update your [`unity firebase messaging`](https://firebase.google.com/docs/unity/setup) dependencies to the latest versions, which use and require `androidX` support libraries. Please see our documentation for more information.

##### Added
- Added `AppboyBinding.RequestImmediateDataFlush()` to immediately request a data flush.
- Added `AppboyBinding.RequestGeofences(latitude, longitude)` to manually request Braze Geofences.
- Adds an option to disable automatic geofence requests on session start. Note that this is required in order to manually request geofences.
- iOS - You can do this in the plist by adding the Appboy dictionary to your Info.plist file. Inside the Appboy dictionary, add the `DisableAutomaticGeofenceRequests` boolean subentry and set the value to `YES`.
- Android - You can do this by configuring the boolean value for `com_appboy_automatic_geofence_requests_enabled` to `false` in your `appboy.xml`.

##### Changed
- Updated the Android plugin to use [Braze Android SDK 5.0.0](https://github.com/Appboy/appboy-android-sdk/blob/master/CHANGELOG.md#500).
- Updated the native iOS bridge to [Braze iOS SDK 3.21.3](https://github.com/Appboy/appboy-ios-sdk/releases/tag/3.21.3).

## 1.22.0

##### Added
Expand Down
49 changes: 23 additions & 26 deletions scripts/generate_package.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
#!/bin/bash

APPBOY_IOS_SDK="Appboy_iOS_SDK.framework"
SD_WEB_IMAGE="SDWebImage.framework"
PROJECT_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )
LIBRARIES_PATH=$PROJECT_ROOT/Libraries
IOS_PLUGINS_PATH=$PROJECT_ROOT/Assets/Plugins/iOS

UNITY_PATH="/Applications/Unity/Unity.app/Contents/MacOS/Unity"
# 64 bit Windows - "C:\Program Files\Unity\Editor\Unity.exe"
# 32 bit Windows - "C:\Program Files (x86)\Unity\Editor\Unity.exe"
# https://unix.stackexchange.com/questions/196690/best-and-short-way-to-run-a-program-if-another-is-not-installed
function unity_app_cmd {
# Ask MacOS for the path of the currently running Unity process
RUNNING_UNITY_APP="$(osascript -e 'tell application "System Events" to POSIX path of (file of process "Unity" as alias)')/Contents/MacOS/Unity"
UNITY_HUB_2018="/Applications/Unity/Hub/Editor/2018.3.10f1/Unity.app/Contents/MacOS/Unity"
UNITY_STANDALONE="/Applications/Unity/Unity.app/Contents/MacOS/Unity"

EXCLUDE_DEPENDENCIES=false # Include dependencies from the Appboy iOS SDK in Unity package
if [[ $1 = "--nodeps" ]]; then
EXCLUDE_DEPENDENCIES=true
fi
if [ -f $RUNNING_UNITY_APP ]
then
echo "Using Unity $RUNNING_UNITY_APP"
$RUNNING_UNITY_APP "$@"

echo "Deleting iOS libraries from Assets/Plugins/iOS/"
[ -e $IOS_PLUGINS_PATH/$APPBOY_IOS_SDK ] && rm -rf $IOS_PLUGINS_PATH/$APPBOY_IOS_SDK*
[ -e $IOS_PLUGINS_PATH/$SD_WEB_IMAGE ] && rm -rf $IOS_PLUGINS_PATH/$SD_WEB_IMAGE*
elif [ -f $UNITY_HUB_2018 ]
then
echo "Using Unity $UNITY_HUB_2018"
$UNITY_HUB_2018 "$@"

else
echo "Using Unity $UNITY_STANDALONE"
$UNITY_STANDALONE "$@"
fi
}

echo "Copying iOS libraries from Libraries/ to Assets/Plugins/iOS/"
cp -R $LIBRARIES_PATH/$APPBOY_IOS_SDK/ $IOS_PLUGINS_PATH/$APPBOY_IOS_SDK/ &
if [ "$EXCLUDE_DEPENDENCIES" = false ]; then
cp -R $LIBRARIES_PATH/$SD_WEB_IMAGE $IOS_PLUGINS_PATH/$SD_WEB_IMAGE
fi &
wait
rm -rf ../unity-package
mkdir ../unity-package

echo "Generating Unity package..."
if [ "$EXCLUDE_DEPENDENCIES" = false ]; then
$UNITY_PATH -batchmode -nographics -projectPath $PROJECT_ROOT -executeMethod Appboy.Editor.Build.ExportPackage -quit && echo "Unity Package exported to $PROJECT_ROOT/unity-package/Appboy.unity-package" || echo "Failed to export package"
else
$UNITY_PATH -batchmode -nographics -projectPath $PROJECT_ROOT -executeMethod Appboy.Editor.Build.ExportPackageWithoutDependencies -quit && echo "Unity Package exported to $PROJECT_ROOT/unity-package/Appboy-nodeps.unity-package" || echo "Failed to export package"
fi
unity_app_cmd -batchmode -nographics -projectPath $PROJECT_ROOT -executeMethod Appboy.Editor.Build.ExportAllPackages -quit \
&& echo "Unity Packages exported to $PROJECT_ROOT/unity-package/" || echo "Failed to export package. Please have your Unity instance running next time!"
4 changes: 4 additions & 0 deletions scripts/get_my_unity_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

RUNNING_UNITY_APP="$(osascript -e 'tell application "System Events" to POSIX path of (file of process "Unity" as alias)')"
echo $RUNNING_UNITY_APP
Loading

0 comments on commit 47e7d57

Please sign in to comment.