Skip to content

Commit

Permalink
SDK-2380 Update SDKs and switch to OpenUPM for EDM4U dependency (#215)
Browse files Browse the repository at this point in the history
* Migrate to Unity 2021.3.18f1
Migrate to OpenUPM version of External Dependency Manager for Unity.

* Update version

* Update to 3.4.3

* Update definition to support changed sharesheet callback

* Update settings in test app

* Expose DMA API

* Add DMA API to android

* Expose DMA endpoint to C#

* Update change log. Also commit updated asset files

* SDK-2274 Add mitigation for overwriting existing settings.

* Updated changelog

* Update AndroidResolverDependencies.xml

---------

Co-authored-by: nsingh-branch <[email protected]>
  • Loading branch information
echo-branch and nsingh-branch authored May 17, 2024
1 parent a0af262 commit c6650df
Show file tree
Hide file tree
Showing 86 changed files with 122 additions and 3,706 deletions.
17 changes: 15 additions & 2 deletions BranchUnityTestBed/Assets/Branch/Branch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class Branch : MonoBehaviour {

public static string sdkVersion = "1.0.0";
public static string sdkVersion = "2.0.0";

public delegate void BranchCallbackWithParams(Dictionary<string, object> parameters, string error);
public delegate void BranchCallbackWithUrl(string url, string error);
Expand Down Expand Up @@ -229,6 +229,10 @@ public static void setTrackingDisabled(bool value) {
_setTrackingDisabled(value);
}

public static void setDMAParamsForEEA(bool eeaRegion, bool adPersonalizationConsent, bool adUserDataUsageConsent) {
_setDMAParamsForEEA(eeaRegion, adPersonalizationConsent, adUserDataUsageConsent);
}

#endregion

#region Send Event methods
Expand Down Expand Up @@ -399,7 +403,10 @@ void OnApplicationPause(bool pauseStatus) {

[DllImport ("__Internal")]
private static extern void _setTrackingDisabled(bool value);


[DllImport ("__Internal")]
private static extern void _setDMAParamsForEEA(bool eeaRegion, bool adPersonalizationConsent, bool adUserDataUsageConsent);

[DllImport ("__Internal")]
private static extern void _sendEvent(string eventName);

Expand Down Expand Up @@ -498,6 +505,10 @@ private static void _setTrackingDisabled(bool value) {
BranchAndroidWrapper.setTrackingDisabled(value);
}

private static void _setDMAParamsForEEA(bool eeaRegion, bool adPersonalizationConsent, bool adUserDataUsageConsent) {
BranchAndroidWrapper.setDMAParamsForEEA(eeaRegion, adPersonalizationConsent, adUserDataUsageConsent);
}

private static void _sendEvent(string eventName) {
BranchAndroidWrapper.sendEvent(eventName);
}
Expand Down Expand Up @@ -572,6 +583,8 @@ private static void _clearPartnerParameters() { }

private static void _setTrackingDisabled(bool value) { }

private static void _setDMAParamsForEEA(bool eeaRegion, bool adPersonalizationConsent, bool adUserDataUsageConsent) { }

private static void _sendEvent(string eventName) { }

private static void _shareLinkWithLinkProperties(string universalObject, string linkProperties, string message,string callbackId) {
Expand Down
6 changes: 6 additions & 0 deletions BranchUnityTestBed/Assets/Branch/BranchAndroidWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ public static void setTrackingDisabled(bool value) {
});
}

public static void setDMAParamsForEEA(bool eeaRegion, bool adPersonalizationConsent, bool adUserDataUsageConsent) {
_runBlockOnThread(() => {
_getBranchClass().CallStatic("setDMAParamsForEEA", eeaRegion, adPersonalizationConsent, adUserDataUsageConsent);
});
}

#endregion

#region Event methods
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<dependencies>
<androidPackages>
<androidPackage spec="io.branch.sdk.android:library:5.8.0" />
<androidPackage spec="io.branch.sdk.android:library:5.12.0" />
<androidPackage spec="com.google.android.gms:play-services-ads-identifier:18+" />
</androidPackages>
<iosPods>
<iosPod name="BranchSDK" version="~>3.0.0" bitcodeEnabled="false" minTargetSdk="14.0" addToAllTargets="false" />
<iosPod name="BranchSDK" version="~>3.4.3" bitcodeEnabled="false" minTargetSdk="14.0" addToAllTargets="false" />
</iosPods>
</dependencies>
38 changes: 37 additions & 1 deletion BranchUnityTestBed/Assets/Branch/Editor/BranchEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,52 @@ public class BranchEditor : Editor {
SerializedProperty serializedTestAppLinks;
SerializedProperty serializedAppLinks;

const string assetPath = "Assets/Branch/Resources/BranchData.asset";
const string copyPath = "Assets/Branch/Resources/BranchDataBackupCopy.asset";


private void OnEnable()
{
// Prevent overwriting settings on SDK upgrade.
// Check for an existing working copy and if it doesn't exist create a new working copy
// In the future, consider versioning and migrating the data.
if (CopyExists()) {
RestoreBranchDataFromCopy();
}

// Loads existing settings
serializedBranchData = new SerializedObject(BranchData.Instance);
serializedTestAppLinks = serializedBranchData.FindProperty("testAppLinks");
serializedAppLinks = serializedBranchData.FindProperty("liveAppLinks");
}

private bool CopyExists()
{
var asset = Resources.Load(copyPath);
if (asset != null) {
return true;
}
return false;
}

private void RestoreBranchDataFromCopy()
{
if (!AssetDatabase.CopyAsset(copyPath, assetPath)) {
Debug.LogWarning($"Failed to restore Branch Settings from a backup Copy");
}
}

private void UpdateBranchDataCopy()
{
if (!AssetDatabase.CopyAsset(assetPath, copyPath)) {
Debug.LogWarning($"Failed to save Branch Settings into a backup Copy");
}
}

public override void OnInspectorGUI() {
GUI.changed = false;

// TODO: handle enableLogging. Due to lifecycle issues it is best to set this in branch.json
// TODO: handle enableLogging. Due to lifecycle issues it is best to set this in branch.json. Which not yet supportted.
SerializedProperty serializedEnableLogging = serializedBranchData.FindProperty("enableLogging");
SerializedProperty serializedIsTestMode = serializedBranchData.FindProperty("testMode");

Expand Down Expand Up @@ -58,6 +93,7 @@ public override void OnInspectorGUI() {
// Android config update is done pre build here.
EditorGUILayout.BeginHorizontal(new GUILayoutOption[]{});
if (GUILayout.Button("Apply Changes", new GUILayoutOption[]{})) {
UpdateBranchDataCopy();
UpdateManifest();
AssetDatabase.Refresh();
}
Expand Down
8 changes: 0 additions & 8 deletions BranchUnityTestBed/Assets/ExternalDependencyManager.meta

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Loading

0 comments on commit c6650df

Please sign in to comment.