├── BranchUnityTestBed ├── Assets │ ├── Resources │ │ ├── BillingMode.json │ │ └── BillingMode.json.meta │ ├── Branch │ │ ├── BranchPrefab.prefab │ │ ├── Demo │ │ │ ├── Fonts │ │ │ │ ├── Calibri Bold.ttf │ │ │ │ └── Calibri Bold.ttf.meta │ │ │ ├── Images │ │ │ │ ├── Unity5_icon.png │ │ │ │ └── Unity5_icon.png.meta │ │ │ ├── Scenes │ │ │ │ ├── BranchSDK_Demo.unity │ │ │ │ ├── BranchSDK_DemoSettings.lighting │ │ │ │ ├── BranchSDK_Demo.unity.meta │ │ │ │ └── BranchSDK_DemoSettings.lighting.meta │ │ │ ├── Prefabs │ │ │ │ ├── RewardTransactionItem.prefab │ │ │ │ └── RewardTransactionItem.prefab.meta │ │ │ ├── Scripts │ │ │ │ ├── RewardTransactionItem.cs │ │ │ │ ├── BranchDemo.cs.meta │ │ │ │ ├── RewardTransactionItem.cs.meta │ │ │ │ ├── RewardsHistoryPanel.cs.meta │ │ │ │ ├── RewardsHistoryPanel.cs │ │ │ │ └── BranchDemo.cs │ │ │ ├── Fonts.meta │ │ │ ├── Images.meta │ │ │ ├── Prefabs.meta │ │ │ ├── Scenes.meta │ │ │ └── Scripts.meta │ │ ├── Resources │ │ │ ├── BranchData.asset │ │ │ └── BranchData.asset.meta │ │ ├── BranchPrefab.prefab.meta │ │ ├── Editor │ │ │ ├── BranchDependencies.xml.meta │ │ │ ├── BranchEditor.cs.meta │ │ │ ├── BranchPostProcessBuild.cs.meta │ │ │ ├── BranchDependencies.xml │ │ │ ├── BranchPostProcessBuild.cs │ │ │ └── BranchEditor.cs │ │ ├── Demo.meta │ │ ├── Editor.meta │ │ ├── Resources.meta │ │ ├── Branch.cs.meta │ │ ├── MiniJSON.cs.meta │ │ ├── BranchAndroidWrapper.cs.meta │ │ ├── BranchQRCode.cs.meta │ │ ├── BranchData.cs.meta │ │ ├── BranchEnums.cs.meta │ │ ├── BranchEvent.cs.meta │ │ ├── BranchContentMetadata.cs.meta │ │ ├── BranchLinkProperties.cs.meta │ │ ├── BranchUniversalObject.cs.meta │ │ ├── BranchData.cs │ │ ├── BranchEvent.cs │ │ ├── BranchLinkProperties.cs │ │ ├── BranchQRCode.cs │ │ ├── BranchUniversalObject.cs │ │ ├── BranchAndroidWrapper.cs │ │ ├── BranchEnums.cs │ │ ├── BranchContentMetadata.cs │ │ └── MiniJSON.cs │ ├── Settings.meta │ ├── Settings │ │ ├── Build Profiles │ │ │ ├── New Android™ Profile.asset │ │ │ └── New Android™ Profile.asset.meta │ │ └── Build Profiles.meta │ ├── Resources.meta │ ├── Plugins │ │ ├── Android.meta │ │ ├── Branch.meta │ │ └── Branch │ │ │ ├── iOS.meta │ │ │ ├── Android.meta │ │ │ ├── Android │ │ │ ├── AndroidManifest.xml.meta │ │ │ ├── BranchUnityApp.java.meta │ │ │ ├── BranchUnityActivity.java.meta │ │ │ ├── BranchUnityWrapper.java.meta │ │ │ ├── BranchUnityApp.java │ │ │ ├── BranchUnityActivity.java │ │ │ └── AndroidManifest.xml │ │ │ └── iOS │ │ │ ├── BranchAppController.mm │ │ │ ├── BranchiOSWrapper.h.meta │ │ │ ├── BranchAppController.mm.meta │ │ │ ├── BranchiOSWrapper.h │ │ │ └── BranchiOSWrapper.mm.meta │ ├── Branch.meta │ └── Plugins.meta ├── ProjectSettings │ ├── Packages │ │ └── com.unity.services.core │ │ │ └── Settings.json │ ├── ProjectVersion.txt │ ├── AudioManager.asset │ ├── InputManager.asset │ ├── NavMeshAreas.asset │ ├── TagManager.asset │ ├── TimeManager.asset │ ├── VFXManager.asset │ ├── ClusterInputManager.asset │ ├── EditorSettings.asset │ ├── NetworkManager.asset │ ├── PresetManager.asset │ ├── DynamicsManager.asset │ ├── GraphicsSettings.asset │ ├── Physics2DSettings.asset │ ├── ProjectSettings.asset │ ├── QualitySettings.asset │ ├── EditorBuildSettings.asset │ ├── UnityConnectSettings.asset │ ├── MultiplayerManager.asset │ ├── XRSettings.asset │ ├── VersionControlSettings.asset │ ├── AndroidResolverDependencies.xml │ ├── MemorySettings.asset │ ├── PackageManagerSettings.asset │ ├── GvhProjectSettings.xml │ └── SceneTemplateSettings.json ├── .vsconfig ├── BranchUnityTestBed.sln └── Packages │ ├── manifest.json │ └── packages-lock.json ├── BranchUnityWrapper.unitypackage ├── README.md ├── SECURITY.md ├── .github ├── ISSUE_TEMPLATE │ ├── feature-request.yml │ ├── config.yml │ └── bug-report.yml ├── workflows │ ├── stale.yml │ └── release-announcement.yml └── PULL_REQUEST_TEMPLATE.md ├── LICENSE ├── .gitignore └── Changelog.md /BranchUnityTestBed/Assets/Resources/BillingMode.json: -------------------------------------------------------------------------------- 1 | {"androidStore":"GooglePlay"} -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/Packages/com.unity.services.core/Settings.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 6000.0.34f1 2 | m_EditorVersionWithRevision: 6000.0.34f1 (5ab2d9ed9190) 3 | -------------------------------------------------------------------------------- /BranchUnityTestBed/.vsconfig: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "components": [ 4 | "Microsoft.VisualStudio.Workload.ManagedGame" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /BranchUnityWrapper.unitypackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityWrapper.unitypackage -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Branch SDK Documentation for Unity 2 | 3 | View [Branch's SDK documentation for Unity](https://help.branch.io/developers-hub/docs/unity) 4 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchPrefab.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/Assets/Branch/BranchPrefab.prefab -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/VFXManager.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/PresetManager.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Fonts/Calibri Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/Assets/Branch/Demo/Fonts/Calibri Bold.ttf -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Images/Unity5_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/Assets/Branch/Demo/Images/Unity5_icon.png -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Resources/BranchData.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/Assets/Branch/Resources/BranchData.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scenes/BranchSDK_Demo.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/Assets/Branch/Demo/Scenes/BranchSDK_Demo.unity -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Prefabs/RewardTransactionItem.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/Assets/Branch/Demo/Prefabs/RewardTransactionItem.prefab -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scenes/BranchSDK_DemoSettings.lighting: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/Assets/Branch/Demo/Scenes/BranchSDK_DemoSettings.lighting -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Resources/BillingMode.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84e8cc1b38e16453b89c2e4e4925c0cd 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Settings.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63ec02684b4e34b9fbc2725a04f536d3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Settings/Build Profiles/New Android™ Profile.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BranchMetrics/unity-branch-deep-linking-attribution/HEAD/BranchUnityTestBed/Assets/Settings/Build Profiles/New Android™ Profile.asset -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchPrefab.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07c514aea4d774a9f8b9a9b641abc819 3 | NativeFormatImporter: 4 | mainObjectFileID: 0 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scripts/RewardTransactionItem.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System.Collections; 4 | 5 | public class RewardTransactionItem : MonoBehaviour { 6 | 7 | public Text label; 8 | } 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2583e46598a1465c9d53301a7957ba0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/MultiplayerManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!655991488 &1 4 | MultiplayerManager: 5 | m_ObjectHideFlags: 0 6 | m_EnableMultiplayerRoles: 0 7 | m_StrippingTypes: {} 8 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Editor/BranchDependencies.xml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6fe444a345f6f49fd8b8643602eafddd 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Android.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d71f9a4f0964840f982620310a274fce 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ebe7d30f73e540a898fcbd116993084 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/iOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3981e2c614fb3488dbe99aff14d23ee8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/Android.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4cbdd535de724c9faedff885e50cd06 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Settings/Build Profiles.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f63e0c73be98642c5b96b46242006e0f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/Android/AndroidManifest.xml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dec5ea02a902442608089322c4a8e0ab 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7f119ee9e34a4c8cb5bb7c376168b81 3 | folderAsset: yes 4 | timeCreated: 1437146867 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scenes/BranchSDK_Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c6ac8a8510fe4b57ae8d9ca3abf1c48 3 | timeCreated: 1438171782 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69bdfce7b98aa463791cc80c5c516a75 3 | folderAsset: yes 4 | timeCreated: 1445258885 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b587bd0cf91144c28f2d9aedb62a539 3 | folderAsset: yes 4 | timeCreated: 1438171744 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb73ee25102bf4899a4f8038d02041d5 3 | folderAsset: yes 4 | timeCreated: 1447319470 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Fonts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1aa4cd945fd9c497aaafa232182285db 3 | folderAsset: yes 4 | timeCreated: 1438172595 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Images.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b895ac2c7f2ee42a3ac4884b5296e8d3 3 | folderAsset: yes 4 | timeCreated: 1438172403 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d9cd12f2dfc046a0bc1a68574bed4ad 3 | folderAsset: yes 4 | timeCreated: 1439151554 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 597c8b0008dca441a8eab65ac5ecf4fd 3 | folderAsset: yes 4 | timeCreated: 1438171757 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2dd7adf397a9e4455a6c00a01fefc51d 3 | folderAsset: yes 4 | timeCreated: 1438171794 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9837a41f0527480aa73a733379fefd1 3 | folderAsset: yes 4 | timeCreated: 1447621366 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Settings/Build Profiles/New Android™ Profile.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e448168f10216486eb62314062888150 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scenes/BranchSDK_DemoSettings.lighting.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7ddb40c466a14323980da226f8ddba6 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 4890085278179872738 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Resources/BranchData.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d76beffc25a4a43028b3295796fbf7ff 3 | timeCreated: 1447622365 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Branch.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e71df0b2569d240ca82cdeccb33502ae 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/MiniJSON.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d623a5d36fe4741a48be74ec28c3af4b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Prefabs/RewardTransactionItem.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b8454f50e2f94ea69c4e9343eb055db 3 | timeCreated: 1439151560 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchAndroidWrapper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 618b95618261540b7ae4f75ffcf23d57 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchQRCode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 670ff746092e840c4b954de8ba4130be 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | If you discover a potential security issue in this project we ask that you notify Branch Security directly via email to security@branch.io 5 | Please do not open GitHub issues or pull requests - this makes the problem immediately visible to everyone, including malicious actors. 6 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac695c03334d64ebd95c3ab403d74540 3 | timeCreated: 1447619925 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchEnums.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2446702710894f3286fd4ae83ac7ce8 3 | timeCreated: 1514205317 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchEvent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4bc0ce5173fb64165895e7a292aff8e7 3 | timeCreated: 1514205316 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Editor/BranchEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d89e96702fa14f3e83ac10e80344416 3 | timeCreated: 1447332148 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchContentMetadata.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90c3de178565b4beeb6cb4cd562ca5fd 3 | timeCreated: 1514205317 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchLinkProperties.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b7d96a28b2df4c2cb2eaf3e31fe3002 3 | timeCreated: 1448110061 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchUniversalObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63df8c15c91d54dd89a89e212b36364c 3 | timeCreated: 1447943295 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scripts/BranchDemo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 726067fd438984074913e1b791bd8bf1 3 | timeCreated: 1438283238 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Editor/BranchPostProcessBuild.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ee27f0b3edbe407da4f5285009667d1 3 | timeCreated: 1447319552 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scripts/RewardTransactionItem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3dc110bf61f664789aa663f0e12e0c64 3 | timeCreated: 1438949049 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scripts/RewardsHistoryPanel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40bdf6d2d01194e619aceb0e904d0947 3 | timeCreated: 1438948479 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Editor/BranchDependencies.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🚀 Feature Request 3 | description: Suggest an idea for this project 4 | title: "(short issue description)" 5 | labels: [feature-request, needs-triage] 6 | assignees: [] 7 | body: 8 | - type: textarea 9 | id: description 10 | attributes: 11 | label: Describe the feature 12 | description: A clear and concise description of the feature you are proposing. 13 | validations: 14 | required: true 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | blank_issues_enabled: false 3 | contact_links: 4 | - name: "📕 Documentation Issue" 5 | url: https://help.branch.io/developers-hub/docs/unity 6 | about: Report an issue in the Branch Unity SDK Reference documentation by clicking "Suggest edits" button on the documentation page. 7 | - name: "Branch Support" 8 | url: https://help.branch.io/using-branch/page/submit-a-ticket 9 | about: If you are having general trouble with Branch Unity SDK integration, please submit a ticket to Branch Support. 10 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Fonts/Calibri Bold.ttf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e8b1f1f5715e4c8c8c949ff3b87db50 3 | timeCreated: 1438172785 4 | licenseType: Pro 5 | TrueTypeFontImporter: 6 | serializedVersion: 4 7 | fontSize: 16 8 | forceTextureCase: -2 9 | characterSpacing: 0 10 | characterPadding: 1 11 | includeFontData: 1 12 | fontName: Calibri 13 | fontNames: 14 | - Calibri 15 | fallbackFontReferences: [] 16 | customCharacters: 17 | fontRenderingMode: 0 18 | ascentCalculationMode: 1 19 | useLegacyBoundsCalculation: 0 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/iOS/BranchAppController.mm: -------------------------------------------------------------------------------- 1 | #import 2 | #import "UnityAppController.h" 3 | #import "UI/UnityView.h" 4 | #import "UI/UnityViewControllerBase.h" 5 | #import "BranchiOSWrapper.h" 6 | 7 | @interface BranchAppController : UnityAppController 8 | 9 | @end 10 | 11 | @implementation BranchAppController 12 | 13 | - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray> *restorableObjects))restorationHandler { 14 | BOOL handledByBranch = [[BranchUnityWrapper sharedInstance] continueUserActivity:userActivity]; 15 | return handledByBranch; 16 | } 17 | 18 | @end 19 | 20 | IMPL_APP_CONTROLLER_SUBCLASS(BranchAppController) 21 | 22 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/Android/BranchUnityApp.java.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5d9fe50d446c640e4aff99273fff10a1 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Android: Android 16 | second: 17 | enabled: 1 18 | settings: {} 19 | - first: 20 | Any: 21 | second: 22 | enabled: 0 23 | settings: {} 24 | - first: 25 | Editor: Editor 26 | second: 27 | enabled: 0 28 | settings: 29 | DefaultValueInitialized: true 30 | userData: 31 | assetBundleName: 32 | assetBundleVariant: 33 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/Android/BranchUnityActivity.java.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4937e539b5764a9290999c754d9b330 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Android: Android 16 | second: 17 | enabled: 1 18 | settings: {} 19 | - first: 20 | Any: 21 | second: 22 | enabled: 0 23 | settings: {} 24 | - first: 25 | Editor: Editor 26 | second: 27 | enabled: 0 28 | settings: 29 | DefaultValueInitialized: true 30 | userData: 31 | assetBundleName: 32 | assetBundleVariant: 33 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/Android/BranchUnityWrapper.java.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df8039207904f40daad5023a55989f46 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Android: Android 16 | second: 17 | enabled: 1 18 | settings: {} 19 | - first: 20 | Any: 21 | second: 22 | enabled: 0 23 | settings: {} 24 | - first: 25 | Editor: Editor 26 | second: 27 | enabled: 0 28 | settings: 29 | DefaultValueInitialized: true 30 | userData: 31 | assetBundleName: 32 | assetBundleVariant: 33 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/Android/BranchUnityApp.java: -------------------------------------------------------------------------------- 1 | package io.branch.unity; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import io.branch.referral.Branch; 7 | 8 | /** 9 | * Created by antonarhunou on 1/9/18. 10 | */ 11 | public class BranchUnityApp extends Application { 12 | private static final String TAG = "BranchSDK.Unity"; 13 | 14 | public void onCreate() { 15 | super.onCreate(); 16 | 17 | // Some early lifecycle events occur prior to C# runtime startup, which prevents the C# APIs from working properly 18 | 19 | // Enables logging for install/open on app launch 20 | //Log.i(TAG, "BranchUnityApp.onCreate()"); 21 | //Branch.enableLogging(); 22 | 23 | // Set plugin version 24 | Branch.registerPlugin("Unity", "2.0.0"); 25 | Branch.disableInstantDeepLinking(true); 26 | Branch.getAutoInstance(this.getApplicationContext()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Branch Metrics, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/Android/BranchUnityActivity.java: -------------------------------------------------------------------------------- 1 | package io.branch.unity; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | 7 | import com.unity3d.player.UnityPlayerActivity; 8 | 9 | import io.branch.referral.Defines; 10 | 11 | /** 12 | * Created by antonarhunou on 10/13/16. 13 | */ 14 | 15 | public class BranchUnityActivity extends UnityPlayerActivity { 16 | 17 | private static final String TAG = "BranchSDK.Unity"; 18 | 19 | @Override 20 | public void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | } 23 | 24 | @Override 25 | public void onStart() { 26 | super.onStart(); 27 | //Log.i(TAG, "BranchUnityActivity.onStart()"); 28 | BranchUnityWrapper.initSession(); 29 | } 30 | 31 | @Override 32 | public void onNewIntent(Intent intent) { 33 | super.onNewIntent(intent); 34 | //Log.i(TAG, "BranchUnityActivity.onNewIntent(Intent intent)"); 35 | 36 | // Unity also triggers a session call from C#, so ignore this to avoid a duplicate call 37 | //BranchUnityWrapper.initSessionWithIntent(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. 2 | # 3 | # You can adjust the behavior by modifying this file. 4 | # For more information, see: 5 | # https://github.com/actions/stale 6 | name: Mark stale issues 7 | 8 | on: 9 | schedule: 10 | - cron: '0 0 * * *' 11 | 12 | jobs: 13 | stale: 14 | 15 | runs-on: ubuntu-latest 16 | permissions: 17 | issues: write 18 | 19 | steps: 20 | - uses: actions/stale@v5 21 | with: 22 | repo-token: ${{ github.token }} 23 | days-before-issue-stale: 60 24 | days-before-close: 7 25 | stale-issue-message: 'This issue has been automatically marked as stale due to inactivity for 60 days. If this issue is still relevant, please respond with any updates or this issue will be closed in 7 days. If you believe this is a mistake, please comment to let us know. Thank you for your contributions.' 26 | stale-issue-label: 'no-issue-activity' 27 | close-issue-message: 'This issue has been closed due to inactivity. If this issue is still relevant, please reopen it or create a new one. Thank you for your contributions.' 28 | start-date: '2023-05-22' 29 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Reference 2 | SDK-XXXX -- . 3 | 4 | ## Summary 5 | <!-- Simple summary of what was changed. --> 6 | 7 | ## Motivation 8 | <!-- Why are you making this change? If it's for fixing a bug, if possible, please include a code snippet or example project that demonstrates the issue. --> 9 | 10 | ## Type Of Change 11 | <!-- Please delete options that are not relevant --> 12 | - [ ] Bug fix (non-breaking change which fixes an issue) 13 | - [ ] New feature (non-breaking change which adds functionality) 14 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 15 | - [ ] This change requires a documentation update 16 | 17 | ## Testing Instructions 18 | <!-- Testing instructions, example code snippets, etc --> 19 | 20 | 21 | <!-- Checklist --> 22 | <!-- My code follows the style guidelines of this project --> 23 | <!-- I have performed a self-review of my code --> 24 | <!-- I have commented my code, particularly in hard-to-understand areas --> 25 | <!-- I have made corresponding changes to the documentation --> 26 | <!-- I have added tests that prove my fix is effective or that my feature works --> 27 | <!-- New and existing unit tests pass locally with my changes --> 28 | 29 | cc @BranchMetrics/saas-sdk-devs for visibility. 30 | -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/AndroidResolverDependencies.xml: -------------------------------------------------------------------------------- 1 | <dependencies> 2 | <packages> 3 | <package>com.google.android.gms:play-services-ads-identifier:18+</package> 4 | <package>com.unity3d.ads:unity-ads:[4.12.0,4.13[</package> 5 | <package>io.branch.sdk.android:library:5.12.0</package> 6 | </packages> 7 | <files /> 8 | <settings> 9 | <setting name="androidAbis" value="armeabi-v7a" /> 10 | <setting name="bundleId" value="io.branch.BranchUnityTestBed" /> 11 | <setting name="explodeAars" value="True" /> 12 | <setting name="gradleBuildEnabled" value="True" /> 13 | <setting name="gradlePropertiesTemplateEnabled" value="True" /> 14 | <setting name="gradleTemplateEnabled" value="True" /> 15 | <setting name="installAndroidPackages" value="True" /> 16 | <setting name="localMavenRepoDir" value="Assets/GeneratedLocalRepo" /> 17 | <setting name="packageDir" value="Assets/Plugins/Android" /> 18 | <setting name="patchAndroidManifest" value="True" /> 19 | <setting name="patchMainTemplateGradle" value="True" /> 20 | <setting name="projectExportEnabled" value="False" /> 21 | <setting name="useFullCustomMavenRepoPathWhenExport" value="True" /> 22 | <setting name="useFullCustomMavenRepoPathWhenNotExport" value="False" /> 23 | <setting name="useJetifier" value="True" /> 24 | </settings> 25 | </dependencies> -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreReleasePackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | m_SeeAllPackageVersions: 0 20 | oneTimeWarningShown: 0 21 | m_Registries: 22 | - m_Id: main 23 | m_Name: 24 | m_Url: https://packages.unity.com 25 | m_Scopes: [] 26 | m_IsDefault: 1 27 | m_Capabilities: 7 28 | m_ConfigSource: 0 29 | - m_Id: scoped:project:package.openupm.com 30 | m_Name: package.openupm.com 31 | m_Url: https://package.openupm.com 32 | m_Scopes: 33 | - com.google.external-dependency-manager 34 | m_IsDefault: 0 35 | m_Capabilities: 0 36 | m_ConfigSource: 4 37 | m_UserSelectedRegistryName: package.openupm.com 38 | m_UserAddingNewScopedRegistry: 0 39 | m_RegistryInfoDraft: 40 | m_Modified: 0 41 | m_ErrorMessage: 42 | m_UserModificationsInstanceId: -828 43 | m_OriginalInstanceId: -830 44 | m_LoadAssets: 0 45 | -------------------------------------------------------------------------------- /BranchUnityTestBed/BranchUnityTestBed.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{67E3F5FC-88EF-55B2-4156-39D21A59D4E6}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor", "Assembly-CSharp-Editor.csproj", "{820AEC7C-7F93-71C7-A37D-1CC603106BE6}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {67E3F5FC-88EF-55B2-4156-39D21A59D4E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {67E3F5FC-88EF-55B2-4156-39D21A59D4E6}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {67E3F5FC-88EF-55B2-4156-39D21A59D4E6}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {67E3F5FC-88EF-55B2-4156-39D21A59D4E6}.Release|Any CPU.Build.0 = Release|Any CPU 18 | {820AEC7C-7F93-71C7-A37D-1CC603106BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {820AEC7C-7F93-71C7-A37D-1CC603106BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {820AEC7C-7F93-71C7-A37D-1CC603106BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {820AEC7C-7F93-71C7-A37D-1CC603106BE6}.Release|Any CPU.Build.0 = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore 4 | # 5 | */[Ll]ibrary/ 6 | */[Tt]emp/ 7 | */[Oo]bj/ 8 | */[Bb]uild/ 9 | */[Bb]uilds/ 10 | */[Ll]ogs/ 11 | */[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Recordings can get excessive in size 18 | /[Rr]ecordings/ 19 | 20 | # ignore the asset store tools plugin 21 | /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.pidb.meta 52 | *.pdb.meta 53 | *.mdb.meta 54 | 55 | # Unity3D generated file on crash reports 56 | sysinfo.txt 57 | 58 | # Builds 59 | *.apk 60 | *.aab 61 | *.app 62 | 63 | # Crashlytics generated file 64 | crashlytics-build.properties 65 | 66 | # Packed Addressables 67 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 68 | 69 | # Temporary auto-generated Android Assets 70 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 71 | /[Aa]ssets/[Ss]treamingAssets/aa/* 72 | 73 | # macOS 74 | *.DS_Store 75 | 76 | # External Dependency Manager resolved Android files 77 | BranchUnityTestBed/Assets/Plugins/Android/* 78 | 79 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchData.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.IO; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor; 7 | [InitializeOnLoad] 8 | #endif 9 | 10 | public class BranchData : ScriptableObject { 11 | 12 | // release data 13 | public string liveBranchKey; 14 | public string liveBranchUri; 15 | public string liveAndroidPathPrefix; 16 | public string[] liveAppLinks; 17 | 18 | // test data 19 | public string testBranchKey; 20 | public string testBranchUri; 21 | public string testAndroidPathPrefix; 22 | public string[] testAppLinks; 23 | 24 | // enable logging? 25 | public bool enableLogging = false; 26 | 27 | // which set of data will we use, test or release? 28 | public bool testMode = false; 29 | 30 | private const string BDAssetPath = "Branch/Resources"; 31 | private const string BDAssetName = "BranchData"; 32 | private const string BDAssetExtension = ".asset"; 33 | private static BranchData instance; 34 | 35 | public static BranchData Instance { 36 | get { 37 | if(instance == null) { 38 | LoadBranchData(); 39 | } 40 | 41 | return instance; 42 | } 43 | } 44 | 45 | private static void LoadBranchData() { 46 | instance = Resources.Load(BDAssetName) as BranchData; 47 | 48 | if(instance == null) { 49 | instance = CreateInstance<BranchData>(); 50 | 51 | #if UNITY_EDITOR 52 | 53 | if (!Directory.Exists(BDAssetPath)) { 54 | Directory.CreateDirectory(BDAssetPath); 55 | AssetDatabase.Refresh(); 56 | } 57 | 58 | string fullPath = Path.Combine(Path.Combine("Assets", BDAssetPath), BDAssetName + BDAssetExtension ); 59 | AssetDatabase.CreateAsset(instance, fullPath); 60 | 61 | #endif 62 | } 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <manifest package="your_package_name" xmlns:android="http://schemas.android.com/apk/res/android"> 3 | <application android:theme="@style/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@string/app_name" android:name="io.branch.unity.BranchUnityApp"> 4 | <activity android:name="io.branch.unity.BranchUnityActivity" android:launchMode="singleTask"> 5 | 6 | <intent-filter> 7 | <action android:name="android.intent.action.MAIN" /> 8 | <category android:name="android.intent.category.LAUNCHER" /> 9 | </intent-filter> 10 | 11 | <intent-filter> 12 | <data android:scheme="APP_URI" android:host="open" /> 13 | <action android:name="android.intent.action.VIEW" /> 14 | <category android:name="android.intent.category.DEFAULT" /> 15 | <category android:name="android.intent.category.BROWSABLE" /> 16 | </intent-filter> 17 | 18 | <intent-filter android:autoVerify="true"> 19 | <data android:scheme="https" android:host="xxxx.app.link" /> 20 | <action android:name="android.intent.action.VIEW" /> 21 | <category android:name="android.intent.category.DEFAULT" /> 22 | <category android:name="android.intent.category.BROWSABLE" /> 23 | </intent-filter> 24 | 25 | <meta-data android:name="unityplayer.UnityActivity" android:value="true" /> 26 | <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" /> 27 | </activity> 28 | 29 | <!-- Optional. Set to true to disable auto deep link feature--> 30 | <meta-data android:name="io.branch.sdk.auto_link_disable" android:value="false"/> 31 | 32 | <!--Set true to simulate fresh installs --> 33 | <meta-data android:name="io.branch.sdk.TestMode" android:value="true" /> 34 | 35 | <!--Branch key--> 36 | <meta-data android:name="io.branch.sdk.BranchKey.test" android:value="key_xxxx" /> 37 | 38 | </application> 39 | 40 | <uses-permission android:name="android.permission.INTERNET" /> 41 | </manifest> 42 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/iOS/BranchiOSWrapper.h.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d81f5ccd0ec944634b29f47ee64c81ea 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Android: Android 16 | second: 17 | enabled: 0 18 | settings: 19 | CPU: AnyCPU 20 | - first: 21 | Any: 22 | second: 23 | enabled: 0 24 | settings: {} 25 | - first: 26 | Editor: Editor 27 | second: 28 | enabled: 0 29 | settings: 30 | CPU: AnyCPU 31 | DefaultValueInitialized: true 32 | OS: AnyOS 33 | - first: 34 | Facebook: Win 35 | second: 36 | enabled: 0 37 | settings: 38 | CPU: AnyCPU 39 | - first: 40 | Facebook: Win64 41 | second: 42 | enabled: 0 43 | settings: 44 | CPU: AnyCPU 45 | - first: 46 | Samsung TV: SamsungTV 47 | second: 48 | enabled: 0 49 | settings: 50 | STV_MODEL: STANDARD_13 51 | - first: 52 | Standalone: Linux 53 | second: 54 | enabled: 0 55 | settings: 56 | CPU: x86 57 | - first: 58 | Standalone: Linux64 59 | second: 60 | enabled: 0 61 | settings: 62 | CPU: AnyCPU 63 | - first: 64 | Standalone: OSXIntel 65 | second: 66 | enabled: 0 67 | settings: 68 | CPU: AnyCPU 69 | - first: 70 | Standalone: OSXIntel64 71 | second: 72 | enabled: 0 73 | settings: 74 | CPU: AnyCPU 75 | - first: 76 | Standalone: Win 77 | second: 78 | enabled: 0 79 | settings: 80 | CPU: AnyCPU 81 | - first: 82 | Standalone: Win64 83 | second: 84 | enabled: 0 85 | settings: 86 | CPU: AnyCPU 87 | - first: 88 | iPhone: iOS 89 | second: 90 | enabled: 1 91 | settings: 92 | CompileFlags: -fobjc-arc 93 | FrameworkDependencies: 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/iOS/BranchAppController.mm.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bc4ea81590c04b059513eb9e3da8677 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Android: Android 16 | second: 17 | enabled: 0 18 | settings: 19 | CPU: AnyCPU 20 | - first: 21 | Any: 22 | second: 23 | enabled: 0 24 | settings: {} 25 | - first: 26 | Editor: Editor 27 | second: 28 | enabled: 0 29 | settings: 30 | CPU: AnyCPU 31 | DefaultValueInitialized: true 32 | OS: AnyOS 33 | - first: 34 | Facebook: Win 35 | second: 36 | enabled: 0 37 | settings: 38 | CPU: AnyCPU 39 | - first: 40 | Facebook: Win64 41 | second: 42 | enabled: 0 43 | settings: 44 | CPU: AnyCPU 45 | - first: 46 | Samsung TV: SamsungTV 47 | second: 48 | enabled: 0 49 | settings: 50 | STV_MODEL: STANDARD_13 51 | - first: 52 | Standalone: Linux 53 | second: 54 | enabled: 0 55 | settings: 56 | CPU: x86 57 | - first: 58 | Standalone: Linux64 59 | second: 60 | enabled: 0 61 | settings: 62 | CPU: AnyCPU 63 | - first: 64 | Standalone: OSXIntel 65 | second: 66 | enabled: 0 67 | settings: 68 | CPU: AnyCPU 69 | - first: 70 | Standalone: OSXIntel64 71 | second: 72 | enabled: 0 73 | settings: 74 | CPU: AnyCPU 75 | - first: 76 | Standalone: Win 77 | second: 78 | enabled: 0 79 | settings: 80 | CPU: AnyCPU 81 | - first: 82 | Standalone: Win64 83 | second: 84 | enabled: 0 85 | settings: 86 | CPU: AnyCPU 87 | - first: 88 | iPhone: iOS 89 | second: 90 | enabled: 1 91 | settings: 92 | CompileFlags: -fobjc-arc 93 | FrameworkDependencies: 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.google.external-dependency-manager": "1.2.183", 4 | "com.unity.2d.sprite": "1.0.0", 5 | "com.unity.2d.tilemap": "1.0.0", 6 | "com.unity.ads": "4.12.0", 7 | "com.unity.ai.navigation": "2.0.5", 8 | "com.unity.analytics": "3.8.1", 9 | "com.unity.collab-proxy": "2.6.0", 10 | "com.unity.ide.rider": "3.0.34", 11 | "com.unity.ide.visualstudio": "2.0.22", 12 | "com.unity.multiplayer.center": "1.0.0", 13 | "com.unity.purchasing": "4.12.2", 14 | "com.unity.test-framework": "1.4.5", 15 | "com.unity.timeline": "1.8.7", 16 | "com.unity.ugui": "2.0.0", 17 | "com.unity.xr.legacyinputhelpers": "2.1.11", 18 | "com.unity.modules.accessibility": "1.0.0", 19 | "com.unity.modules.ai": "1.0.0", 20 | "com.unity.modules.androidjni": "1.0.0", 21 | "com.unity.modules.animation": "1.0.0", 22 | "com.unity.modules.assetbundle": "1.0.0", 23 | "com.unity.modules.audio": "1.0.0", 24 | "com.unity.modules.cloth": "1.0.0", 25 | "com.unity.modules.director": "1.0.0", 26 | "com.unity.modules.imageconversion": "1.0.0", 27 | "com.unity.modules.imgui": "1.0.0", 28 | "com.unity.modules.jsonserialize": "1.0.0", 29 | "com.unity.modules.particlesystem": "1.0.0", 30 | "com.unity.modules.physics": "1.0.0", 31 | "com.unity.modules.physics2d": "1.0.0", 32 | "com.unity.modules.screencapture": "1.0.0", 33 | "com.unity.modules.terrain": "1.0.0", 34 | "com.unity.modules.terrainphysics": "1.0.0", 35 | "com.unity.modules.tilemap": "1.0.0", 36 | "com.unity.modules.ui": "1.0.0", 37 | "com.unity.modules.uielements": "1.0.0", 38 | "com.unity.modules.umbra": "1.0.0", 39 | "com.unity.modules.unityanalytics": "1.0.0", 40 | "com.unity.modules.unitywebrequest": "1.0.0", 41 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 42 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 43 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 44 | "com.unity.modules.unitywebrequestwww": "1.0.0", 45 | "com.unity.modules.vehicles": "1.0.0", 46 | "com.unity.modules.video": "1.0.0", 47 | "com.unity.modules.vr": "1.0.0", 48 | "com.unity.modules.wind": "1.0.0", 49 | "com.unity.modules.xr": "1.0.0" 50 | }, 51 | "scopedRegistries": [ 52 | { 53 | "name": "package.openupm.com", 54 | "url": "https://package.openupm.com", 55 | "scopes": [ 56 | "com.google.external-dependency-manager" 57 | ] 58 | } 59 | ] 60 | } 61 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.yml: -------------------------------------------------------------------------------- 1 | --- 2 | assignees: [] 3 | body: 4 | - 5 | attributes: 6 | description: "What is the problem? A clear and concise description of what the bug is." 7 | label: "Describe the bug" 8 | placeholder: "Tell us what you see!" 9 | id: description 10 | type: textarea 11 | validations: 12 | required: true 13 | - 14 | attributes: 15 | description: "Please provide as much step-by-step detail as possible including logs, stack traces, and uncaught exceptions." 16 | label: "Steps to reproduce" 17 | value: | 18 | 1. 19 | 2. 20 | 3. 21 | id: steps 22 | type: textarea 23 | validations: 24 | required: true 25 | - 26 | attributes: 27 | description: "What did you expect to happen?" 28 | label: "Expected behavior" 29 | id: expected 30 | type: textarea 31 | validations: 32 | required: true 33 | - 34 | attributes: 35 | description: "What version of sdk are you seeing this issue on?" 36 | label: "SDK Version" 37 | placeholder: "0.6.7" 38 | id: sdk-version 39 | type: input 40 | validations: 41 | required: true 42 | - 43 | attributes: 44 | description: "What version of the Unity are you using?" 45 | label: Unity Version 46 | placeholder: "2022.1.15" 47 | id: unity-version 48 | type: input 49 | validations: 50 | required: true 51 | - 52 | attributes: 53 | description: "What devices or emulators are you seeing this bug on?" 54 | label: Make and Model 55 | placeholder: "iPhone 13 / Samsung S21" 56 | id: device 57 | type: input 58 | validations: 59 | required: true 60 | - 61 | attributes: 62 | description: "What version of the device OS?" 63 | label: OS 64 | placeholder: "iOS 15.6.1 / Android 12" 65 | id: os 66 | type: input 67 | validations: 68 | required: true 69 | - 70 | attributes: 71 | description: "Anything else that might be relevant for troubleshooting this bug. Any screenshots or videos that show the issue are very helpful." 72 | label: "Additional Information/Context" 73 | id: context 74 | type: textarea 75 | validations: 76 | required: false 77 | 78 | description: "Found a bug in the Branch Unity SDK? File it here." 79 | labels: 80 | - bug 81 | - needs-triage 82 | name: "🐞 Bug report" 83 | title: "(short issue description)" 84 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Images/Unity5_icon.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8021710004784435983b1ec16593221e 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: -1 32 | maxTextureSize: 2048 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: -1 36 | aniso: 16 37 | mipBias: -100 38 | wrapU: 1 39 | wrapV: 1 40 | wrapW: 1 41 | nPOTScale: 0 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 1 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 1 54 | spriteTessellationDetail: -1 55 | textureType: 8 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | flipbookRows: 1 59 | flipbookColumns: 1 60 | maxTextureSizeSet: 0 61 | compressionQualitySet: 0 62 | textureFormatSet: 0 63 | ignorePngGamma: 0 64 | applyGammaDecoding: 1 65 | platformSettings: 66 | - serializedVersion: 3 67 | buildTarget: DefaultTexturePlatform 68 | maxTextureSize: 2048 69 | resizeAlgorithm: 0 70 | textureFormat: -1 71 | textureCompression: 1 72 | compressionQuality: 50 73 | crunchedCompression: 0 74 | allowsAlphaSplitting: 0 75 | overridden: 0 76 | androidETC2FallbackOverride: 0 77 | forceMaximumCompressionQuality_BC6H_BC7: 1 78 | spriteSheet: 79 | serializedVersion: 2 80 | sprites: [] 81 | outline: [] 82 | physicsShape: [] 83 | bones: [] 84 | spriteID: 5e97eb03825dee720800000000000000 85 | internalID: 0 86 | vertices: [] 87 | indices: 88 | edges: [] 89 | weights: [] 90 | secondaryTextures: [] 91 | spritePackingTag: 92 | pSDRemoveMatte: 0 93 | pSDShowRemoveMatteOption: 0 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /.github/workflows/release-announcement.yml: -------------------------------------------------------------------------------- 1 | name: Announce SDK Release on Slack 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | update-changelog: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Announce New Release in Slack 13 | uses: slackapi/slack-github-action@v1.24.0 14 | with: 15 | channel-id: "C063MQJMKJN" #sdk-releases 16 | payload: | 17 | { 18 | "text": "New Release: Branch Unity SDK v${{ github.event.release.tag_name }}", 19 | "blocks": [ 20 | { 21 | "type": "header", 22 | "text": { 23 | "type": "plain_text", 24 | "text": ":rocket: New Release: Branch Unity SDK v${{ github.event.release.tag_name }}", 25 | "emoji": true 26 | } 27 | }, 28 | { 29 | "type": "divider" 30 | }, 31 | { 32 | "type": "section", 33 | "text": { 34 | "type": "mrkdwn", 35 | "text": ":star: *What's New*" 36 | } 37 | }, 38 | { 39 | "type": "section", 40 | "text": { 41 | "type": "mrkdwn", 42 | "text": ${{ toJSON(github.event.release.body) }} 43 | } 44 | }, 45 | { 46 | "type": "divider" 47 | }, 48 | { 49 | "type": "actions", 50 | "elements": [ 51 | { 52 | "type": "button", 53 | "text": { 54 | "type": "plain_text", 55 | "text": ":git: GitHub Release", 56 | "emoji": true 57 | }, 58 | "value": "github", 59 | "action_id": "github", 60 | "url": "${{ github.event.release.html_url }}" 61 | } 62 | ] 63 | } 64 | ] 65 | } 66 | env: 67 | SLACK_BOT_TOKEN: ${{ secrets.SLACK_SDK_BOT_TOKEN }} 68 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/iOS/BranchiOSWrapper.h: -------------------------------------------------------------------------------- 1 | #import "AppDelegateListener.h" 2 | 3 | #pragma mark - Private notification class interface 4 | 5 | typedef void (^callbackWithShareCompletion) (NSString *activityType, BOOL completed, NSError *error); 6 | 7 | @interface BranchUnityWrapper : NSObject<AppDelegateListener> 8 | + (BranchUnityWrapper *)sharedInstance; 9 | - (BOOL)continueUserActivity:(NSUserActivity *)userActivity; 10 | @end 11 | 12 | #pragma mark - Unity plugin methods 13 | 14 | extern "C" { 15 | #pragma mark - Key methods 16 | 17 | void _setBranchKey(char *branchKey, char* branchSDKVersion); 18 | 19 | #pragma mark - InitSession methods 20 | 21 | void _initSessionWithCallback(char *callbackId); 22 | void _initSessionWithUniversalObjectCallback(char *callbackId); 23 | 24 | #pragma mark - Session Item methods 25 | 26 | const char *_getFirstReferringBranchUniversalObject(); 27 | const char *_getFirstReferringBranchLinkProperties(); 28 | const char *_getLatestReferringBranchUniversalObject(); 29 | const char *_getLatestReferringBranchLinkProperties(); 30 | void _resetUserSession(); 31 | void _setIdentity(char *userId); 32 | void _setIdentityWithCallback(char *userId, char *callbackId); 33 | void _logout(); 34 | 35 | # pragma mark - Configuration methods 36 | 37 | void _enableLogging(); 38 | void _setRetryInterval(int retryInterval); 39 | void _setMaxRetries(int maxRetries); 40 | void _setNetworkTimeout(int timeout); 41 | void _registerView(char *universalObjectJson); 42 | void _listOnSpotlight(char *universalObjectJson); 43 | void _setRequestMetadata(char *key, char *value); 44 | void _addFacebookPartnerParameter(char *name, char *value); 45 | void _clearPartnerParameters(); 46 | void _setTrackingDisabled(BOOL value); 47 | void _setDMAParamsForEEA(BOOL eeaRegion, BOOL adPersonalizationConsent, BOOL adUserDataUsageConsent); 48 | 49 | #pragma mark - Send event methods 50 | 51 | void _sendEvent(char *eventJson); 52 | 53 | #pragma mark - Short URL Generation methods 54 | 55 | void _getShortURLWithBranchUniversalObjectAndCallback(char *universalObjectJson, char *linkPropertiesJson, char *callbackId); 56 | 57 | #pragma mark - Share Link methods 58 | 59 | void _shareLinkWithLinkProperties(char *universalObjectJson, char *linkPropertiesJson, char *message, char *callbackId); 60 | 61 | #pragma mark - QR Code methods 62 | 63 | void _generateBranchQRCode(char *universalObjectJson, char *linkPropertiesJson, char *qrCodeSettingsJson, char *callbackId); 64 | 65 | void _validate(); 66 | } 67 | 68 | -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/GvhProjectSettings.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <projectSettings> 3 | <projectSetting /> 4 | <projectSetting name="com.google.external-dependency-managerAnalyticsEnabled" value="False" /> 5 | <projectSetting name="com.google.unity.oss.play_services_resolverAnalyticsCookie" value="116598dd7d804b168bdae735c457b3b5" /> 6 | <projectSetting name="com.google.unity.oss.play_services_resolverAnalyticsEnabled" value="True" /> 7 | <projectSetting name="Google.IOSResolver.VerboseLoggingEnabled" value="True" /> 8 | <projectSetting name="Google.PackageManagerResolver.Enable" value="True" /> 9 | <projectSetting name="Google.PackageManagerResolver.PromptToAddRegistries" value="True" /> 10 | <projectSetting name="Google.PackageManagerResolver.PromptToMigratePackages" value="True" /> 11 | <projectSetting name="Google.PackageManagerResolver.VerboseLoggingEnabled" value="True" /> 12 | <projectSetting name="Google.VersionHandler.CleanUpPromptEnabled" value="True" /> 13 | <projectSetting name="Google.VersionHandler.RenameToCanonicalFilenames" value="False" /> 14 | <projectSetting name="Google.VersionHandler.RenameToDisableFilesEnabled" value="True" /> 15 | <projectSetting name="Google.VersionHandler.VerboseLoggingEnabled" value="False" /> 16 | <projectSetting name="Google.VersionHandler.VersionHandlingEnabled" value="True" /> 17 | <projectSetting name="GooglePlayServices.AndroidPackageInstallationEnabled" value="True" /> 18 | <projectSetting name="GooglePlayServices.AutoResolutionDisabledWarning" value="True" /> 19 | <projectSetting name="GooglePlayServices.AutoResolveOnBuild" value="True" /> 20 | <projectSetting name="GooglePlayServices.AutoResolverEnabled" value="False" /> 21 | <projectSetting name="GooglePlayServices.ExplodeAars" value="True" /> 22 | <projectSetting name="GooglePlayServices.LocalMavenRepoDir" value="Assets/GeneratedLocalRepo" /> 23 | <projectSetting name="GooglePlayServices.PatchAndroidManifest" value="True" /> 24 | <projectSetting name="GooglePlayServices.PatchMainTemplateGradle" value="True" /> 25 | <projectSetting name="GooglePlayServices.PatchPropertiesTemplateGradle" value="True" /> 26 | <projectSetting name="GooglePlayServices.PatchSettingsTemplateGradle" value="True" /> 27 | <projectSetting name="GooglePlayServices.PromptBeforeAutoResolution" value="True" /> 28 | <projectSetting name="GooglePlayServices.UseFullCustomMavenRepoPathWhenExport" value="True" /> 29 | <projectSetting name="GooglePlayServices.UseFullCustomMavenRepoPathWhenNotExport" value="False" /> 30 | <projectSetting name="GooglePlayServices.UseGradleDaemon" value="False" /> 31 | <projectSetting name="GooglePlayServices.UseJetifier" value="True" /> 32 | <projectSetting name="GooglePlayServices.UserRejectedGradleUpgrade" value="False" /> 33 | <projectSetting name="GooglePlayServices.VerboseLogging" value="True" /> 34 | </projectSettings> -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Plugins/Branch/iOS/BranchiOSWrapper.mm.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9661e5228ca4844abbebb88b3f1bee7e 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Android: 1 20 | Exclude Editor: 1 21 | Exclude Linux: 1 22 | Exclude Linux64: 1 23 | Exclude LinuxUniversal: 1 24 | Exclude OSXIntel: 1 25 | Exclude OSXIntel64: 1 26 | Exclude OSXUniversal: 1 27 | Exclude SamsungTV: 1 28 | Exclude Tizen: 1 29 | Exclude WebGL: 1 30 | Exclude Win: 1 31 | Exclude Win64: 1 32 | Exclude iOS: 0 33 | Exclude tvOS: 1 34 | - first: 35 | Android: Android 36 | second: 37 | enabled: 0 38 | settings: 39 | CPU: ARMv7 40 | - first: 41 | Any: 42 | second: 43 | enabled: 0 44 | settings: {} 45 | - first: 46 | Editor: Editor 47 | second: 48 | enabled: 0 49 | settings: 50 | CPU: AnyCPU 51 | DefaultValueInitialized: true 52 | OS: AnyOS 53 | - first: 54 | Facebook: Win 55 | second: 56 | enabled: 0 57 | settings: 58 | CPU: AnyCPU 59 | - first: 60 | Facebook: Win64 61 | second: 62 | enabled: 0 63 | settings: 64 | CPU: AnyCPU 65 | - first: 66 | Samsung TV: SamsungTV 67 | second: 68 | enabled: 0 69 | settings: 70 | STV_MODEL: STANDARD_15 71 | - first: 72 | Standalone: Linux 73 | second: 74 | enabled: 0 75 | settings: 76 | CPU: x86 77 | - first: 78 | Standalone: Linux64 79 | second: 80 | enabled: 0 81 | settings: 82 | CPU: AnyCPU 83 | - first: 84 | Standalone: OSXIntel 85 | second: 86 | enabled: 0 87 | settings: 88 | CPU: AnyCPU 89 | - first: 90 | Standalone: OSXIntel64 91 | second: 92 | enabled: 0 93 | settings: 94 | CPU: AnyCPU 95 | - first: 96 | Standalone: Win 97 | second: 98 | enabled: 0 99 | settings: 100 | CPU: AnyCPU 101 | - first: 102 | Standalone: Win64 103 | second: 104 | enabled: 0 105 | settings: 106 | CPU: AnyCPU 107 | - first: 108 | iPhone: iOS 109 | second: 110 | enabled: 1 111 | settings: 112 | CompileFlags: -fobjc-arc 113 | FrameworkDependencies: 114 | - first: 115 | tvOS: tvOS 116 | second: 117 | enabled: 0 118 | settings: 119 | CompileFlags: 120 | FrameworkDependencies: 121 | userData: 122 | assetBundleName: 123 | assetBundleVariant: 124 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchEvent.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class BranchEvent { 6 | 7 | private Dictionary<string, object> data = new Dictionary<string, object>(); 8 | private Dictionary<string, string> customData = new Dictionary<string, string>(); 9 | private List<string> contentItems = new List<string>(); 10 | 11 | // Create custom BranchEvent 12 | public BranchEvent(string customEventName) { 13 | AddData("event_name", customEventName); 14 | } 15 | 16 | // Create standard BranchEvent 17 | public BranchEvent(BranchEventType branchEventType) { 18 | AddData("event_name", branchEventType.ToString ()); 19 | } 20 | 21 | // Set the alias 22 | public void SetAlias(string alias) { 23 | AddData("customer_event_alias", alias); 24 | } 25 | 26 | // Set the transaction id associated with this event if there in any 27 | public void SetTransactionID(string transactionID) { 28 | AddData ("transaction_id", transactionID); 29 | } 30 | 31 | // Set any affiliation for this transaction event 32 | public void SetAffiliation(string affiliation) { 33 | AddData ("affiliation", affiliation); 34 | } 35 | 36 | // Set any coupons associated with this transaction event 37 | public void SetCoupon(string coupon) { 38 | AddData ("coupon", coupon); 39 | } 40 | 41 | // Set the currency related with this transaction event 42 | public void SetCurrency(BranchCurrencyType currency) { 43 | AddData ("currency", currency.ToString()); 44 | } 45 | 46 | // Set the tax value related with this transaction event 47 | public void SetTax(float tax) { 48 | AddData ("tax", tax); 49 | } 50 | 51 | // Set the revenue value related with this transaction event 52 | public void SetRevenue(float revenue) { 53 | AddData ("revenue", revenue); 54 | } 55 | 56 | // Set description for this transaction event 57 | public void SetDescription(string description) { 58 | AddData ("description", description); 59 | } 60 | 61 | // Set the shipping value related with this transaction event 62 | public void SetShipping(float shipping) { 63 | AddData ("shipping", shipping); 64 | } 65 | 66 | // Set any search query associated with the event 67 | public void SetSearchQuery(string searchQuery) { 68 | AddData ("search_query", searchQuery); 69 | } 70 | 71 | // Adds a custom data property associated with this Branch Event 72 | public void AddCustomData(string key, string value) { 73 | if (!customData.ContainsKey(key)) { 74 | customData.Add (key, value); 75 | } 76 | else{ 77 | customData [key] = value; 78 | } 79 | } 80 | 81 | // Use this method to add any BranchUniversalObject associated with this event 82 | public void AddContentItem(BranchUniversalObject contentItem) { 83 | contentItems.Add (contentItem.ToJsonString ()); 84 | } 85 | 86 | public string ToJsonString() { 87 | var dataToSend = new Dictionary<string, object>(data); 88 | 89 | if (customData.Count > 0) { 90 | dataToSend.Add ("custom_data", customData); 91 | } 92 | 93 | if (contentItems.Count > 0) { 94 | dataToSend.Add ("content_items", contentItems); 95 | } 96 | 97 | return BranchThirdParty_MiniJSON.Json.Serialize(dataToSend); 98 | } 99 | 100 | private void AddData(string key, object value) { 101 | if (!data.ContainsKey(key)) { 102 | data.Add (key, value); 103 | } 104 | else{ 105 | data [key] = value; 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchLinkProperties.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System; 5 | 6 | public class BranchLinkProperties { 7 | 8 | public List<String> tags; 9 | public string feature; 10 | public string alias; 11 | public string channel; 12 | public string stage; 13 | public int matchDuration; 14 | public Dictionary<String, String> controlParams; 15 | 16 | 17 | public BranchLinkProperties() { 18 | tags = new List<String>(); 19 | feature = ""; 20 | alias = ""; 21 | channel = ""; 22 | stage = ""; 23 | matchDuration = 0; 24 | controlParams = new Dictionary<String, String>(); 25 | } 26 | 27 | public BranchLinkProperties(string json) { 28 | tags = new List<String>(); 29 | feature = ""; 30 | alias = ""; 31 | channel = ""; 32 | stage = ""; 33 | matchDuration = 0; 34 | controlParams = new Dictionary<String, String>(); 35 | 36 | loadFromJson(json); 37 | } 38 | 39 | public BranchLinkProperties(Dictionary<string, object> data) { 40 | tags = new List<String>(); 41 | feature = ""; 42 | alias = ""; 43 | channel = ""; 44 | stage = ""; 45 | matchDuration = 0; 46 | controlParams = new Dictionary<String, String>(); 47 | 48 | loadFromDictionary(data); 49 | } 50 | 51 | public void loadFromJson(string json) { 52 | if (string.IsNullOrEmpty(json)) 53 | return; 54 | 55 | var data = BranchThirdParty_MiniJSON.Json.Deserialize(json) as Dictionary<string, object>; 56 | loadFromDictionary(data); 57 | } 58 | 59 | public void loadFromDictionary(Dictionary<string, object> data) { 60 | if (data == null) 61 | return; 62 | 63 | if (data.ContainsKey("~tags") && data["~tags"] != null) { 64 | List<object> tempList = data["~tags"] as List<object>; 65 | 66 | if (tempList != null) { 67 | foreach(object obj in tempList) { 68 | if (obj != null) { 69 | tags.Add (obj.ToString ()); 70 | } 71 | } 72 | } 73 | } 74 | if (data.ContainsKey("~feature") && data["~feature"] != null) { 75 | feature = data["~feature"].ToString(); 76 | } 77 | if (data.ContainsKey("~alias") && data["~alias"] != null) { 78 | alias = data["~alias"].ToString(); 79 | } 80 | if (data.ContainsKey("~channel") && data["~channel"] != null) { 81 | channel = data["~channel"].ToString(); 82 | } 83 | if (data.ContainsKey("~stage") && data["~stage"] != null) { 84 | stage = data["~stage"].ToString(); 85 | } 86 | if (data.ContainsKey("~duration")) { 87 | if (!string.IsNullOrEmpty(data["~duration"].ToString())) { 88 | matchDuration = Convert.ToInt32(data["~duration"].ToString()); 89 | } 90 | } 91 | if (data.ContainsKey("control_params")) { 92 | if (data["control_params"] != null) { 93 | Dictionary<string, object> paramsTemp = data["control_params"] as Dictionary<string, object>; 94 | 95 | if (paramsTemp != null) { 96 | foreach(string key in paramsTemp.Keys) { 97 | if (paramsTemp [key] != null) { 98 | controlParams.Add (key, paramsTemp [key].ToString ()); 99 | } 100 | } 101 | } 102 | } 103 | } 104 | } 105 | 106 | public string ToJsonString() { 107 | var data = new Dictionary<string, object>(); 108 | 109 | data.Add("~tags", tags); 110 | data.Add("~feature", feature); 111 | data.Add("~alias", alias); 112 | data.Add("~channel", channel); 113 | data.Add("~stage", stage); 114 | data.Add("~duration", matchDuration.ToString()); 115 | data.Add("control_params", controlParams); 116 | 117 | return BranchThirdParty_MiniJSON.Json.Serialize(data); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchQRCode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class BranchQRCode 5 | { 6 | //Primary color of the generated QR code itself 7 | private string codeColor; 8 | 9 | //Secondary color used as the QR Code background 10 | private string backgroundColor; 11 | 12 | //The number of pixels for the QR code's border. Min 1px. Max 20px 13 | private int margin; 14 | 15 | //Output size of QR Code image. Min 300px. Max 2000px 16 | private int width; 17 | 18 | //Image Format of the returned QR code. Can be a JPEG or PNG 19 | private BranchImageFormat imageFormat; 20 | 21 | //A URL of an image that will be added to the center of the QR code. Must be a PNG or JPEG 22 | private string centerLogoUrl; 23 | 24 | //The style of code pattern used to generate the QR-Code 25 | private BranchQRCodePattern codePattern; 26 | 27 | // The style of finder pattern used to generate the QR-Code 28 | private BranchQRCodeFinderPattern finderPattern; 29 | 30 | // Hex string used to change the color of the Qr-Code’s finder pattern 31 | private string finderPatternColor; 32 | 33 | // Direct link to an image to be used as the background image that is set behind the QR Code 34 | private string backgroundImageUrl; 35 | 36 | // Adjusts the opacity of the background image 37 | private int backgroundImageOpacity; 38 | 39 | // Direct link to an image to be used as the code-pattern itself on the QR Code 40 | private string codePatternUrl; 41 | 42 | // Hex string used to change the color of the interior part of a Qr-Code’s finder pattern 43 | private string finderEyeColor; 44 | 45 | public BranchQRCode(string codeColor = "#000000", string backgroundColor = "#FFFFFF", int margin = 1, int width = 512, BranchImageFormat imageFormat = BranchImageFormat.PNG, string centerLogoUrl = "") 46 | { 47 | Init(codeColor, backgroundColor, margin, width, imageFormat, centerLogoUrl); 48 | } 49 | 50 | private void Init(string codeColor, string backgroundColor, int margin, int width, BranchImageFormat imageFormat, string centerLogoUrl) 51 | { 52 | this.codeColor = codeColor; 53 | this.backgroundColor = backgroundColor; 54 | this.margin = margin; 55 | this.width = width; 56 | this.imageFormat = imageFormat; 57 | this.centerLogoUrl = centerLogoUrl; 58 | } 59 | 60 | public void loadFromJson(string json) 61 | { 62 | if (string.IsNullOrEmpty(json)) 63 | return; 64 | 65 | var data = BranchThirdParty_MiniJSON.Json.Deserialize(json) as Dictionary<string, object>; 66 | loadFromDictionary(data); 67 | } 68 | 69 | public void loadFromDictionary(Dictionary<string, object> data) 70 | { 71 | if (data == null) 72 | return; 73 | 74 | if (data.ContainsKey("code_color") && data["code_color"] != null) 75 | { 76 | codeColor = data["code_color"].ToString(); 77 | } 78 | if (data.ContainsKey("background_color") && data["background_color"] != null) 79 | { 80 | backgroundColor = data["background_color"].ToString(); 81 | } 82 | if (data.ContainsKey("margin")) 83 | { 84 | margin = Convert.ToInt32(data["margin"].ToString()); 85 | } 86 | if (data.ContainsKey("width")) 87 | { 88 | width = Convert.ToInt32(data["width"].ToString()); 89 | } 90 | if (data.ContainsKey("image_format")) 91 | { 92 | imageFormat = (BranchImageFormat) Convert.ToInt32(data["imageFormat"].ToString()); 93 | } 94 | if (data.ContainsKey("center_logo_url") && data["center_logo_url"] != null) 95 | { 96 | centerLogoUrl = data["center_logo_url"].ToString(); 97 | } 98 | } 99 | 100 | public string ToJsonString() 101 | { 102 | var data = new Dictionary<string, object>(); 103 | 104 | data.Add("code_color", codeColor); 105 | data.Add("background_color", backgroundColor); 106 | data.Add("margin", margin.ToString()); 107 | data.Add("width", width.ToString()); 108 | data.Add("image_format", imageFormat.ToString()); 109 | data.Add("center_logo_url", centerLogoUrl); 110 | 111 | return BranchThirdParty_MiniJSON.Json.Serialize(data); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scripts/RewardsHistoryPanel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | public class RewardsHistoryPanel : MonoBehaviour { 7 | 8 | public ScrollRect scroll; 9 | public GameObject contentContainer; 10 | public GameObject itemPrefab; 11 | private List<RewardTransactionItem> items = new List<RewardTransactionItem>(); 12 | 13 | void OnDisable() { 14 | foreach(RewardTransactionItem obj in items) 15 | Destroy(obj.gameObject); 16 | 17 | items.Clear(); 18 | } 19 | 20 | void AddItem(string text) { 21 | GameObject item = Instantiate(itemPrefab) as GameObject; 22 | 23 | if (item != null) { 24 | item.GetComponent<RewardTransactionItem>().label.text = text; 25 | item.transform.SetParent(contentContainer.transform, false); 26 | items.Add(item.GetComponent<RewardTransactionItem>()); 27 | item.SetActive(true); 28 | } 29 | } 30 | 31 | #region Parse list of object 32 | 33 | // historyList is list of 34 | // Dictionary<string,object> 35 | // { 36 | // transaction : Dictionary<string,object> 37 | // { 38 | // type : int 39 | // id : string 40 | // bucket : string 41 | // amount : int 42 | // date : string 43 | // } 44 | // 45 | // event : Dictionary<string,object> 46 | // { 47 | // name : string (optional) 48 | // 49 | // metadata : Dictionary<string,object> 50 | // { 51 | // ip : string (optional) 52 | // } 53 | // } 54 | // 55 | // referrer : string (optional) 56 | // referree : string (optional) 57 | 58 | void Parse(List<object> list, List<string> resList) { 59 | string res = ""; 60 | 61 | foreach(object dict in list) { 62 | if (dict != null && dict.GetType() == typeof(Dictionary<string, object>)) { 63 | res = ParseTransaction(dict as Dictionary<string, object>); 64 | res += " "; 65 | res += ParseEvent(dict as Dictionary<string, object>); 66 | res += " "; 67 | res += ParseReferrer(dict as Dictionary<string, object>); 68 | res += " "; 69 | res += ParseReferree(dict as Dictionary<string, object>); 70 | 71 | resList.Add(res); 72 | } 73 | } 74 | } 75 | 76 | string ParseTransaction(Dictionary<string, object> dict) { 77 | string strRes = ""; 78 | 79 | if (dict.ContainsKey("transaction")) { 80 | Dictionary<string, object> transactionDict = dict["transaction"] as Dictionary<string, object>; 81 | 82 | if (transactionDict != null) { 83 | if (transactionDict.ContainsKey("type") && transactionDict["type"] != null) { 84 | strRes += "type = " + transactionDict["type"].ToString(); 85 | } 86 | 87 | if (transactionDict.ContainsKey("id") && transactionDict["id"] != null) { 88 | strRes += " id = " + transactionDict["id"].ToString(); 89 | } 90 | 91 | if (transactionDict.ContainsKey("bucket") && transactionDict["bucket"] != null) { 92 | strRes += " bucket = " + transactionDict["bucket"].ToString(); 93 | } 94 | 95 | if (transactionDict.ContainsKey("amount") && transactionDict["amount"] != null) { 96 | strRes += " amount = " + transactionDict["amount"].ToString(); 97 | } 98 | 99 | if (transactionDict.ContainsKey("date") && transactionDict["date"] != null) { 100 | strRes += " date = " + transactionDict["date"].ToString(); 101 | } 102 | } 103 | } 104 | 105 | return strRes; 106 | } 107 | 108 | string ParseEvent(Dictionary<string, object> dict) { 109 | string strRes = ""; 110 | 111 | if (dict.ContainsKey("event")) { 112 | Dictionary<string, object> transactionDict = dict["event"] as Dictionary<string, object>; 113 | 114 | if (transactionDict != null) { 115 | if (transactionDict.ContainsKey("name") && transactionDict["name"] != null) { 116 | strRes += " name = " + transactionDict["name"].ToString(); 117 | } 118 | 119 | if (transactionDict.ContainsKey("metadata") && transactionDict["metadata"] != null) { 120 | Dictionary<string, object> dictMetadata = transactionDict["metadata"] as Dictionary<string, object>; 121 | 122 | if (dictMetadata != null && dictMetadata.ContainsKey("ip") && dictMetadata["ip"] != null) { 123 | strRes += " ip = " + dictMetadata["ip"].ToString(); 124 | } 125 | } 126 | } 127 | } 128 | 129 | return strRes; 130 | } 131 | 132 | string ParseReferrer(Dictionary<string, object> dict) { 133 | string strRes = ""; 134 | 135 | if (dict != null && dict.ContainsKey("referrer") && dict["referrer"] != null ) { 136 | strRes += " referrer = " + dict["referrer"].ToString(); 137 | } 138 | 139 | return strRes; 140 | } 141 | 142 | string ParseReferree(Dictionary<string, object> dict) { 143 | string strRes = ""; 144 | 145 | if (dict != null && dict.ContainsKey("referree") && dict["referree"] != null ) { 146 | strRes += " referree = " + dict["referree"].ToString(); 147 | } 148 | 149 | return strRes; 150 | } 151 | 152 | #endregion 153 | } 154 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchUniversalObject.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System; 5 | 6 | public class BranchUniversalObject { 7 | 8 | // Canonical identifier for the content referred. Normally the canonical path for your content in the app or web 9 | public string canonicalIdentifier; 10 | 11 | // Canonical url for the content referred. This would be the corresponding website URL 12 | public string canonicalUrl; 13 | 14 | // Title for the content referred by BranchUniversalObject 15 | public string title; 16 | 17 | // Description for the content referred 18 | public string contentDescription; 19 | 20 | // An image url associated with the content referred 21 | public string imageUrl; 22 | 23 | // Meta data provided for the content. This meta data is used as the link parameters for links created from this object 24 | public BranchContentMetadata metadata; 25 | 26 | // Content index mode: 0 - private mode, 1 - public mode 27 | public int contentIndexMode; 28 | 29 | // Content index mode: 0 - private mode, 1 - public mode 30 | public int localIndexMode; 31 | 32 | // Any keyword associated with the content. Used for indexing 33 | public List<String> keywords; 34 | 35 | // Expiry date for the content and any associated links 36 | public DateTime? expirationDate = null; 37 | 38 | 39 | public BranchUniversalObject() { 40 | Init (); 41 | } 42 | 43 | public BranchUniversalObject(string json) { 44 | Init (); 45 | loadFromJson(json); 46 | } 47 | 48 | public BranchUniversalObject(Dictionary<string, object> data) { 49 | Init (); 50 | loadFromDictionary(data); 51 | } 52 | 53 | private void Init() { 54 | canonicalIdentifier = ""; 55 | canonicalUrl = ""; 56 | title = ""; 57 | contentDescription = ""; 58 | imageUrl = ""; 59 | metadata = new BranchContentMetadata (); 60 | contentIndexMode = 0; 61 | localIndexMode = 0; 62 | keywords = new List<string>(); 63 | expirationDate = new DateTime(2200, 12, 30); 64 | } 65 | 66 | public void loadFromJson(string json) { 67 | if (string.IsNullOrEmpty(json)) 68 | return; 69 | 70 | var data = BranchThirdParty_MiniJSON.Json.Deserialize(json) as Dictionary<string, object>; 71 | loadFromDictionary(data); 72 | } 73 | 74 | public void loadFromDictionary(Dictionary<string, object> data) { 75 | if (data == null) 76 | return; 77 | 78 | expirationDate = new DateTime(2200, 12, 30); 79 | 80 | if (data.ContainsKey("$canonical_identifier") && data["$canonical_identifier"] != null) { 81 | canonicalIdentifier = data["$canonical_identifier"].ToString(); 82 | } 83 | if (data.ContainsKey("$canonical_url") && data["$canonical_url"] != null) { 84 | canonicalUrl = data["$canonical_url"].ToString(); 85 | } 86 | if (data.ContainsKey("$og_title") && data["$og_title"] != null) { 87 | title = data["$og_title"].ToString(); 88 | } 89 | if (data.ContainsKey("$og_description") && data["$og_description"] != null) { 90 | contentDescription = data["$og_description"].ToString(); 91 | } 92 | if (data.ContainsKey("$og_image_url") && data["$og_image_url"] != null) { 93 | imageUrl = data["$og_image_url"].ToString(); 94 | } 95 | if (data.ContainsKey("$publicly_indexable")) { 96 | if (!string.IsNullOrEmpty(data["$publicly_indexable"].ToString())) { 97 | contentIndexMode = Convert.ToInt32(data["$publicly_indexable"].ToString()); 98 | } 99 | } 100 | if (data.ContainsKey("$locally_indexable")) { 101 | if (!string.IsNullOrEmpty(data["$locally_indexable"].ToString())) { 102 | localIndexMode = Convert.ToInt32(data["$locally_indexable"].ToString()); 103 | } 104 | } 105 | if (data.ContainsKey("$exp_date")) { 106 | if (!string.IsNullOrEmpty(data["$exp_date"].ToString())) { 107 | expirationDate = new DateTime(Convert.ToInt64(data["$exp_date"].ToString()) * 10000); // milliseconds to ticks 108 | } 109 | } 110 | if (data.ContainsKey("$keywords")) { 111 | if (data["$keywords"] != null) { 112 | List<object> keywordsTemp = data["$keywords"] as List<object>; 113 | 114 | if (keywordsTemp != null) { 115 | foreach(object obj in keywordsTemp) { 116 | keywords.Add(obj.ToString()); 117 | } 118 | } 119 | } 120 | } 121 | if (data.ContainsKey("metadata")) { 122 | if (data["metadata"] != null) { 123 | Dictionary<string, object> metaTemp = data["metadata"] as Dictionary<string, object>; 124 | 125 | if (metaTemp != null) { 126 | metadata.loadFromDictionary (metaTemp); 127 | } 128 | } 129 | } 130 | } 131 | 132 | public string ToJsonString() { 133 | var data = new Dictionary<string, object>(); 134 | 135 | data.Add("$canonical_identifier", canonicalIdentifier); 136 | data.Add("$canonical_url", canonicalUrl); 137 | data.Add("$og_title", title); 138 | data.Add("$og_description", contentDescription); 139 | data.Add("$og_image_url", imageUrl); 140 | data.Add("$publicly_indexable", contentIndexMode.ToString()); 141 | data.Add("$locally_indexable", localIndexMode.ToString()); 142 | data.Add("$exp_date", expirationDate.HasValue ? (expirationDate.Value.Ticks / 10000).ToString() : "0"); // ticks to milliseconds 143 | data.Add("$keywords", keywords); 144 | data.Add("metadata", metadata.ToJsonString()); 145 | 146 | return BranchThirdParty_MiniJSON.Json.Serialize(data); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /BranchUnityTestBed/ProjectSettings/SceneTemplateSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "templatePinStates": [], 3 | "dependencyTypeInfos": [ 4 | { 5 | "userAdded": false, 6 | "type": "UnityEngine.AnimationClip", 7 | "ignore": false, 8 | "defaultInstantiationMode": 0, 9 | "supportsModification": true 10 | }, 11 | { 12 | "userAdded": false, 13 | "type": "UnityEditor.Animations.AnimatorController", 14 | "ignore": false, 15 | "defaultInstantiationMode": 0, 16 | "supportsModification": true 17 | }, 18 | { 19 | "userAdded": false, 20 | "type": "UnityEngine.AnimatorOverrideController", 21 | "ignore": false, 22 | "defaultInstantiationMode": 0, 23 | "supportsModification": true 24 | }, 25 | { 26 | "userAdded": false, 27 | "type": "UnityEditor.Audio.AudioMixerController", 28 | "ignore": false, 29 | "defaultInstantiationMode": 0, 30 | "supportsModification": true 31 | }, 32 | { 33 | "userAdded": false, 34 | "type": "UnityEngine.ComputeShader", 35 | "ignore": true, 36 | "defaultInstantiationMode": 1, 37 | "supportsModification": true 38 | }, 39 | { 40 | "userAdded": false, 41 | "type": "UnityEngine.Cubemap", 42 | "ignore": false, 43 | "defaultInstantiationMode": 0, 44 | "supportsModification": true 45 | }, 46 | { 47 | "userAdded": false, 48 | "type": "UnityEngine.GameObject", 49 | "ignore": false, 50 | "defaultInstantiationMode": 0, 51 | "supportsModification": true 52 | }, 53 | { 54 | "userAdded": false, 55 | "type": "UnityEditor.LightingDataAsset", 56 | "ignore": false, 57 | "defaultInstantiationMode": 0, 58 | "supportsModification": false 59 | }, 60 | { 61 | "userAdded": false, 62 | "type": "UnityEngine.LightingSettings", 63 | "ignore": false, 64 | "defaultInstantiationMode": 0, 65 | "supportsModification": true 66 | }, 67 | { 68 | "userAdded": false, 69 | "type": "UnityEngine.Material", 70 | "ignore": false, 71 | "defaultInstantiationMode": 0, 72 | "supportsModification": true 73 | }, 74 | { 75 | "userAdded": false, 76 | "type": "UnityEditor.MonoScript", 77 | "ignore": true, 78 | "defaultInstantiationMode": 1, 79 | "supportsModification": true 80 | }, 81 | { 82 | "userAdded": false, 83 | "type": "UnityEngine.PhysicMaterial", 84 | "ignore": false, 85 | "defaultInstantiationMode": 0, 86 | "supportsModification": true 87 | }, 88 | { 89 | "userAdded": false, 90 | "type": "UnityEngine.PhysicsMaterial2D", 91 | "ignore": false, 92 | "defaultInstantiationMode": 0, 93 | "supportsModification": true 94 | }, 95 | { 96 | "userAdded": false, 97 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", 98 | "ignore": false, 99 | "defaultInstantiationMode": 0, 100 | "supportsModification": true 101 | }, 102 | { 103 | "userAdded": false, 104 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", 105 | "ignore": false, 106 | "defaultInstantiationMode": 0, 107 | "supportsModification": true 108 | }, 109 | { 110 | "userAdded": false, 111 | "type": "UnityEngine.Rendering.VolumeProfile", 112 | "ignore": false, 113 | "defaultInstantiationMode": 0, 114 | "supportsModification": true 115 | }, 116 | { 117 | "userAdded": false, 118 | "type": "UnityEditor.SceneAsset", 119 | "ignore": false, 120 | "defaultInstantiationMode": 0, 121 | "supportsModification": false 122 | }, 123 | { 124 | "userAdded": false, 125 | "type": "UnityEngine.Shader", 126 | "ignore": true, 127 | "defaultInstantiationMode": 1, 128 | "supportsModification": true 129 | }, 130 | { 131 | "userAdded": false, 132 | "type": "UnityEngine.ShaderVariantCollection", 133 | "ignore": true, 134 | "defaultInstantiationMode": 1, 135 | "supportsModification": true 136 | }, 137 | { 138 | "userAdded": false, 139 | "type": "UnityEngine.Texture", 140 | "ignore": false, 141 | "defaultInstantiationMode": 0, 142 | "supportsModification": true 143 | }, 144 | { 145 | "userAdded": false, 146 | "type": "UnityEngine.Texture2D", 147 | "ignore": false, 148 | "defaultInstantiationMode": 0, 149 | "supportsModification": true 150 | }, 151 | { 152 | "userAdded": false, 153 | "type": "UnityEngine.Timeline.TimelineAsset", 154 | "ignore": false, 155 | "defaultInstantiationMode": 0, 156 | "supportsModification": true 157 | } 158 | ], 159 | "defaultDependencyTypeInfo": { 160 | "userAdded": false, 161 | "type": "<default_scene_template_dependencies>", 162 | "ignore": false, 163 | "defaultInstantiationMode": 1, 164 | "supportsModification": true 165 | }, 166 | "newSceneOverride": 0 167 | } -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Editor/BranchPostProcessBuild.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_IOS 2 | 3 | using UnityEngine; 4 | using UnityEditor; 5 | using UnityEditor.Callbacks; 6 | using System.Collections; 7 | using UnityEditor.iOS.Xcode; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Xml; 11 | using System.IO; 12 | 13 | public class BranchPostProcessBuild 14 | { 15 | 16 | [PostProcessBuild(900)] 17 | public static void ChangeBranchBuiltProject(BuildTarget buildTarget, string pathToBuiltProject) { 18 | if ( buildTarget == BuildTarget.iOS ) { 19 | UpdateXcodePlist(pathToBuiltProject); 20 | UpdateXcodeProject(pathToBuiltProject); 21 | UpdateEntitlements(pathToBuiltProject); 22 | } 23 | } 24 | 25 | private static void UpdateXcodePlist(string pathToBuiltProject) { 26 | string plistPath = pathToBuiltProject + "/Info.plist"; 27 | PlistDocument plist = new PlistDocument(); 28 | plist.ReadFromString(File.ReadAllText(plistPath)); 29 | 30 | UpdateBranchKeys(plist); 31 | UpdateURIs(plist); 32 | 33 | // Write to file 34 | File.WriteAllText(plistPath, plist.WriteToString()); 35 | } 36 | 37 | private static void UpdateBranchKeys(PlistDocument plist) 38 | { 39 | PlistElementDict rootDict = plist.root; 40 | PlistElementDict branchKeyDict = null; 41 | 42 | if (!rootDict.values.ContainsKey("branch_key")) { 43 | branchKeyDict = rootDict.CreateDict("branch_key"); 44 | } else { 45 | branchKeyDict = rootDict.values["branch_key"].AsDict(); 46 | if (branchKeyDict == null) { 47 | branchKeyDict = rootDict.CreateDict("branch_key"); 48 | } 49 | } 50 | 51 | if (BranchData.Instance.liveBranchKey != null && BranchData.Instance.liveBranchKey.Length > 0) { 52 | branchKeyDict.SetString("live", BranchData.Instance.liveBranchKey); 53 | } 54 | 55 | if (BranchData.Instance.testBranchKey != null && BranchData.Instance.testBranchKey.Length > 0) { 56 | branchKeyDict.SetString("test", BranchData.Instance.testBranchKey); 57 | } 58 | } 59 | 60 | private static void UpdateURIs(PlistDocument plist) 61 | { 62 | PlistElementDict rootDict = plist.root; 63 | PlistElementArray urlTypesArray = null; 64 | PlistElementDict urlTypesDict = null; 65 | PlistElementArray urlSchemesArray = null; 66 | 67 | // URL types 68 | if (!rootDict.values.ContainsKey("CFBundleURLTypes")) { 69 | urlTypesArray = rootDict.CreateArray("CFBundleURLTypes"); 70 | } else { 71 | urlTypesArray = rootDict.values["CFBundleURLTypes"].AsArray(); 72 | if (urlTypesArray == null) { 73 | urlTypesArray = rootDict.CreateArray("CFBundleURLTypes"); 74 | } 75 | } 76 | 77 | if (urlTypesArray.values.Count == 0) { 78 | urlTypesDict = urlTypesArray.AddDict(); 79 | } else { 80 | urlTypesDict = urlTypesArray.values[0].AsDict(); 81 | if (urlTypesDict == null) { 82 | urlTypesDict = urlTypesArray.AddDict(); 83 | } 84 | } 85 | 86 | // URL Schemes 87 | if (!urlTypesDict.values.ContainsKey("CFBundleURLSchemes")) { 88 | urlSchemesArray = urlTypesDict.CreateArray("CFBundleURLSchemes"); 89 | } else { 90 | urlSchemesArray = urlTypesDict.values["CFBundleURLSchemes"].AsArray(); 91 | 92 | if (urlSchemesArray == null) { 93 | urlSchemesArray = urlTypesDict.CreateArray("CFBundleURLSchemes"); 94 | } 95 | } 96 | 97 | // delete old branch URIs 98 | foreach(PlistElement elem in urlSchemesArray.values) { 99 | if (elem.AsString() != null && elem.AsString().Equals(BranchData.Instance.liveBranchUri)) { 100 | urlSchemesArray.values.Remove(elem); 101 | break; 102 | } 103 | } 104 | 105 | foreach(PlistElement elem in urlSchemesArray.values) { 106 | if (elem.AsString() != null && elem.AsString().Equals(BranchData.Instance.testBranchUri)) { 107 | urlSchemesArray.values.Remove(elem); 108 | break; 109 | } 110 | } 111 | 112 | // add branch URIs 113 | if (BranchData.Instance.testMode && !string.IsNullOrEmpty(BranchData.Instance.testBranchUri) ) { 114 | urlSchemesArray.AddString(BranchData.Instance.testBranchUri); 115 | } 116 | else if (!BranchData.Instance.testMode && !string.IsNullOrEmpty(BranchData.Instance.liveBranchUri)) { 117 | urlSchemesArray.AddString(BranchData.Instance.liveBranchUri); 118 | } 119 | } 120 | 121 | private static void UpdateEntitlements(string pathToBuiltProject) 122 | { 123 | string projectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; 124 | string targetName = "Unity-iPhone"; 125 | string entitlementsFileName = "branch_domains.entitlements"; 126 | 127 | var entitlements = new ProjectCapabilityManager(projectPath, entitlementsFileName, targetName); 128 | 129 | entitlements.AddAssociatedDomains(BuildEntitlements()); 130 | entitlements.WriteToFile(); 131 | } 132 | 133 | private static string[] BuildEntitlements() 134 | { 135 | var links = BranchData.Instance.liveAppLinks; 136 | if (BranchData.Instance.testMode) { 137 | links = BranchData.Instance.testAppLinks; 138 | } 139 | 140 | if (links == null) { 141 | return null; 142 | } 143 | 144 | string[] domains = new string[links.Length]; 145 | for (int i = 0; i < links.Length; i++) 146 | { 147 | domains[i] = "applinks:" + links[i]; 148 | } 149 | 150 | return domains; 151 | } 152 | 153 | private static void UpdateXcodeProject(string pathToBuiltProject) { 154 | string pathToProject = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; 155 | string[] lines = File.ReadAllLines(pathToProject); 156 | 157 | // We'll open/replace project.pbxproj for writing and iterate over the old 158 | // file in memory, copying the original file and inserting every extra we need. 159 | // Create new file and open it for read and write, if the file exists overwrite it. 160 | FileStream fileProject = new FileStream(pathToProject, FileMode.Create); 161 | fileProject.Close(); 162 | 163 | StreamWriter fCurrentXcodeProjFile = new StreamWriter(pathToProject) ; 164 | 165 | foreach (string line in lines) { 166 | 167 | // The C# to ObjC code is bridged by C++ enable a few flags 168 | if (line.Contains("GCC_ENABLE_OBJC_EXCEPTIONS")) { 169 | fCurrentXcodeProjFile.Write("\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;\n"); 170 | } 171 | else if (line.Contains("GCC_ENABLE_CPP_EXCEPTIONS")) { 172 | fCurrentXcodeProjFile.Write("\t\t\t\tGCC_ENABLE_CPP_EXCEPTIONS = YES;\n"); 173 | } 174 | else if (line.Contains("CLANG_ENABLE_MODULES")) { 175 | fCurrentXcodeProjFile.Write("\t\t\t\tCLANG_ENABLE_MODULES = YES;\n"); 176 | } 177 | else if (line.Contains("ENABLE_BITCODE")) { 178 | // Apple deprecated bitcode, Unity still enables it as of March 2, 2023 179 | fCurrentXcodeProjFile.Write("\t\t\t\tENABLE_BITCODE = NO;\n"); 180 | } 181 | else { 182 | fCurrentXcodeProjFile.WriteLine(line); 183 | } 184 | } 185 | fCurrentXcodeProjFile.Close(); 186 | } 187 | } 188 | #endif 189 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchAndroidWrapper.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Runtime.InteropServices; 4 | using System; 5 | 6 | public class BranchAndroidWrapper { 7 | #if UNITY_ANDROID 8 | 9 | public static void setBranchKey(String branchKey, String sdkVersion) { 10 | _runBlockOnThread(() => { 11 | _getBranchClass().CallStatic("setBranchKey", branchKey, sdkVersion); 12 | }); 13 | } 14 | 15 | #region InitSession methods 16 | 17 | public static void initSessionWithCallback(string callbackId) { 18 | _runBlockOnThread(() => { 19 | _getBranchClass().CallStatic("initSession", callbackId); 20 | }); 21 | } 22 | 23 | public static void initSessionWithUniversalObjectCallback(string callbackId) { 24 | _runBlockOnThread(() => { 25 | _getBranchClass().CallStatic("initSessionWithUniversalObjectCallback", callbackId); 26 | }); 27 | } 28 | 29 | #endregion 30 | 31 | #region Session Item methods 32 | 33 | public static string getFirstReferringBranchUniversalObject() { 34 | return _getBranchClass().CallStatic<string>("getFirstReferringBranchUniversalObject"); 35 | } 36 | 37 | public static string getFirstReferringBranchLinkProperties() { 38 | return _getBranchClass().CallStatic<string>("getFirstReferringBranchLinkProperties"); 39 | } 40 | 41 | public static string getLatestReferringBranchUniversalObject() { 42 | return _getBranchClass().CallStatic<string>("getLatestReferringBranchUniversalObject"); 43 | } 44 | 45 | public static string getLatestReferringBranchLinkProperties() { 46 | return _getBranchClass().CallStatic<string>("getLatestReferringBranchLinkProperties"); 47 | } 48 | 49 | public static void resetUserSession() { 50 | _runBlockOnThread(() => { 51 | _getBranchClass().CallStatic("resetUserSession"); 52 | }); 53 | } 54 | 55 | public static void setIdentity(string userId) { 56 | _runBlockOnThread(() => { 57 | _getBranchClass().CallStatic("setIdentity", userId); 58 | }); 59 | } 60 | 61 | //INTENG-20830 62 | public static void setFBAppID(string facebookAppID) 63 | { 64 | _runBlockOnThread(() => { 65 | _getBranchClass().CallStatic("setFBAppID", facebookAppID); 66 | }); 67 | } 68 | 69 | public static void setIdentityWithCallback(string userId, string callbackId) { 70 | _runBlockOnThread(() => { 71 | _getBranchClass().CallStatic("setIdentity", userId, callbackId); 72 | }); 73 | } 74 | 75 | public static void logout() { 76 | _runBlockOnThread(() => { 77 | _getBranchClass().CallStatic("logout"); 78 | }); 79 | } 80 | 81 | #endregion 82 | 83 | #region Configuration methods 84 | 85 | public static void enableLogging() { 86 | _runBlockOnThread(() => { 87 | _getBranchClass().CallStatic("enableLogging"); 88 | }); 89 | } 90 | 91 | public static void setRetryInterval(int retryInterval) { 92 | _runBlockOnThread(() => { 93 | _getBranchClass().CallStatic("setRetryInterval", retryInterval); 94 | }); 95 | } 96 | 97 | public static void setMaxRetries(int maxRetries) { 98 | _runBlockOnThread(() => { 99 | _getBranchClass().CallStatic("setMaxRetries", maxRetries); 100 | }); 101 | } 102 | 103 | public static void setNetworkTimeout(int timeout) { 104 | _runBlockOnThread(() => { 105 | _getBranchClass().CallStatic("setNetworkTimeout", timeout); 106 | }); 107 | } 108 | 109 | public static void registerView(string universalObject) { 110 | _runBlockOnThread(() => { 111 | _getBranchClass().CallStatic("registerView", universalObject); 112 | }); 113 | } 114 | 115 | public static void listOnSpotlight(string universalObject) { 116 | _runBlockOnThread(() => { 117 | _getBranchClass().CallStatic("listOnSpotlight", universalObject); 118 | }); 119 | } 120 | 121 | public static void setRequestMetadata(string key, string val) { 122 | _runBlockOnThread(() => { 123 | _getBranchClass().CallStatic("setRequestMetadata", key, val); 124 | }); 125 | } 126 | 127 | public static void addFacebookPartnerParameter(string name, string val) { 128 | _runBlockOnThread(() => { 129 | _getBranchClass().CallStatic("addFacebookPartnerParameter", name, val); 130 | }); 131 | } 132 | 133 | public static void clearPartnerParameters() { 134 | _runBlockOnThread(() => { 135 | _getBranchClass().CallStatic("clearPartnerParameters"); 136 | }); 137 | } 138 | 139 | public static void setTrackingDisabled(bool value) { 140 | _runBlockOnThread(() => { 141 | _getBranchClass().CallStatic("setTrackingDisabled", value); 142 | }); 143 | } 144 | 145 | public static void setDMAParamsForEEA(bool eeaRegion, bool adPersonalizationConsent, bool adUserDataUsageConsent) { 146 | _runBlockOnThread(() => { 147 | _getBranchClass().CallStatic("setDMAParamsForEEA", eeaRegion, adPersonalizationConsent, adUserDataUsageConsent); 148 | }); 149 | } 150 | 151 | #endregion 152 | 153 | #region Event methods 154 | 155 | public static void sendEvent(string eventName) { 156 | _runBlockOnThread(() => { 157 | _getBranchClass().CallStatic("sendEvent", eventName); 158 | }); 159 | } 160 | 161 | #endregion 162 | 163 | #region Share Link methods 164 | 165 | public static void shareLinkWithLinkProperties(string universalObject, string linkProperties, string message, string callbackId) { 166 | _runBlockOnThread(() => { 167 | _getBranchClass().CallStatic("shareLinkWithLinkProperties", universalObject, linkProperties, message, callbackId); 168 | }); 169 | } 170 | 171 | #endregion 172 | 173 | #region Short URL Generation methods 174 | 175 | public static void getShortURLWithBranchUniversalObjectAndCallback(string universalObject, string linkProperties, string callbackId) { 176 | _runBlockOnThread(() => { 177 | _getBranchClass().CallStatic("getShortURLWithBranchUniversalObject", universalObject, linkProperties, callbackId); 178 | }); 179 | } 180 | 181 | #endregion 182 | 183 | #region QR Code Generation methods 184 | 185 | public static void generateBranchQRCode(string universalObject, string linkProperties, string branchQRCode, string callbackId) 186 | { 187 | _runBlockOnThread(() => { 188 | _getBranchClass().CallStatic("generateBranchQRCode", universalObject, linkProperties, branchQRCode, callbackId); 189 | }); 190 | } 191 | 192 | #endregion 193 | 194 | #region Validator methods 195 | 196 | public static void validate() { 197 | _runBlockOnThread(() => { 198 | _getBranchClass().CallStatic("validate"); 199 | }); 200 | } 201 | 202 | #endregion 203 | 204 | #region Utility methods 205 | 206 | private static AndroidJavaClass _getBranchClass() { 207 | if (_branchClass == null) { 208 | _branchClass = new AndroidJavaClass("io/branch/unity/BranchUnityWrapper"); 209 | } 210 | 211 | return _branchClass; 212 | } 213 | 214 | private static void _runBlockOnThread(Action runBlock) { 215 | var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); 216 | var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); 217 | 218 | activity.Call("runOnUiThread", new AndroidJavaRunnable(runBlock)); 219 | } 220 | 221 | #endregion 222 | 223 | private static AndroidJavaClass _branchClass; 224 | private static AndroidJavaClass _validatorClass; 225 | 226 | #endif 227 | } 228 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchEnums.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public enum BranchCurrencyType { 6 | AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, 7 | BDT, BGN, BHD, BIF, BMD, BND, BOB, BOV, BRL, BSD, BTN, BWP, 8 | BYN, BYR, BZD, CAD, CDF, CHE, CHF, CHW, CLF, CLP, CNY, COP, 9 | COU, CRC, CUC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, 10 | ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, 11 | HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, 12 | JOD, JPY, KES, KGS, KHR, KMF, KPW, KRW, KWD, KYD, KZT, LAK, 13 | LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, 14 | MRO, MUR, MVR, MWK, MXN, MXV, MYR, MZN, NAD, NGN, NIO, NOK, 15 | NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, 16 | RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, 17 | SRD, SSP, STD, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, 18 | TWD, TZS, UAH, UGX, USD, USN, UYI, UYU, UZS, VEF, VND, VUV, 19 | WST, XAF, XAG, XAU, XBA, XBB, XBC, XBD, XCD, XDR, XFU, XOF, 20 | XPD, XPF, XPT, XSU, XTS, XUA, XXX, YER, ZAR, ZMW, NONE 21 | } 22 | 23 | public enum BranchEventType { 24 | // Commerce events 25 | ADD_TO_CART, 26 | ADD_TO_WISHLIST, 27 | VIEW_CART, 28 | INITIATE_PURCHASE, 29 | ADD_PAYMENT_INFO, 30 | PURCHASE, 31 | SUBSCRIBE, 32 | START_TRIAL, 33 | CLICK_AD, 34 | VIEW_AD, 35 | 36 | // Content events 37 | SEARCH, 38 | VIEW_ITEM, 39 | VIEW_ITEMS, 40 | RATE, 41 | SHARE, 42 | 43 | // User lifecycle events 44 | COMPLETE_REGISTRATION, 45 | COMPLETE_TUTORIAL, 46 | ACHIEVE_LEVEL, 47 | UNLOCK_ACHIEVEMENT, 48 | INVITE, 49 | LOGIN, 50 | RESERVE 51 | } 52 | 53 | public enum BranchContentSchema { 54 | COMMERCE_AUCTION, 55 | COMMERCE_BUSINESS, 56 | COMMERCE_OTHER, 57 | COMMERCE_PRODUCT, 58 | COMMERCE_RESTAURANT, 59 | COMMERCE_SERVICE, 60 | COMMERCE_TRAVEL_FLIGHT, 61 | COMMERCE_TRAVEL_HOTEL, 62 | COMMERCE_TRAVEL_OTHER, 63 | GAME_STATE, 64 | MEDIA_IMAGE, 65 | MEDIA_MIXED, 66 | MEDIA_MUSIC, 67 | MEDIA_OTHER, 68 | MEDIA_VIDEO, 69 | OTHER, 70 | TEXT_ARTICLE, 71 | TEXT_BLOG, 72 | TEXT_OTHER, 73 | TEXT_RECIPE, 74 | TEXT_REVIEW, 75 | TEXT_SEARCH_RESULTS, 76 | TEXT_STORY, 77 | TEXT_TECHNICAL_DOC, 78 | NONE 79 | } 80 | 81 | public enum BranchProductCategory { 82 | ANIMALS_AND_PET_SUPPLIES, 83 | APPAREL_AND_ACCESSORIES, 84 | ARTS_AND_ENTERTAINMENT, 85 | BABY_AND_TODDLER, 86 | BUSINESS_AND_INDUSTRIAL, 87 | CAMERAS_AND_OPTICS, 88 | ELECTRONICS, 89 | FOOD_BEVERAGES_AND_TOBACCO, 90 | FURNITURE, 91 | HARDWARE, 92 | HEALTH_AND_BEAUTY, 93 | HOME_AND_GARDEN, 94 | LUGGAGE_AND_BAGS, 95 | MATURE, 96 | MEDIA, 97 | OFFICE_SUPPLIES, 98 | RELIGIOUS_AND_CEREMONIAL, 99 | SOFTWARE, 100 | SPORTING_GOODS, 101 | TOYS_AND_GAMES, 102 | VEHICLES_AND_PARTS, 103 | NONE 104 | } 105 | 106 | public enum BranchCondition { 107 | OTHER, NEW, GOOD, FAIR, POOR, USED, REFURBISHED, EXCELLENT, NONE 108 | } 109 | 110 | public static class BranchEnumExtensions 111 | { 112 | public static string toString(this BranchProductCategory category) 113 | { 114 | switch(category) { 115 | case BranchProductCategory.ANIMALS_AND_PET_SUPPLIES: 116 | return "Animals & Pet Supplies"; 117 | case BranchProductCategory.APPAREL_AND_ACCESSORIES: 118 | return "Apparel & Accessories"; 119 | case BranchProductCategory.ARTS_AND_ENTERTAINMENT: 120 | return "Arts & Entertainment"; 121 | case BranchProductCategory.BABY_AND_TODDLER: 122 | return "Baby & Toddler"; 123 | case BranchProductCategory.BUSINESS_AND_INDUSTRIAL: 124 | return "Business & Industrial"; 125 | case BranchProductCategory.CAMERAS_AND_OPTICS: 126 | return "Cameras & Optics"; 127 | case BranchProductCategory.ELECTRONICS: 128 | return "Electronics"; 129 | case BranchProductCategory.FOOD_BEVERAGES_AND_TOBACCO: 130 | return "Food, Beverages & Tobacco"; 131 | case BranchProductCategory.FURNITURE: 132 | return "Furniture"; 133 | case BranchProductCategory.HARDWARE: 134 | return "Hardware"; 135 | case BranchProductCategory.HEALTH_AND_BEAUTY: 136 | return "Health & Beauty"; 137 | case BranchProductCategory.HOME_AND_GARDEN: 138 | return "Home & Garden"; 139 | case BranchProductCategory.LUGGAGE_AND_BAGS: 140 | return "Luggage & Bags"; 141 | case BranchProductCategory.MATURE: 142 | return "Mature"; 143 | case BranchProductCategory.MEDIA: 144 | return "Media"; 145 | case BranchProductCategory.OFFICE_SUPPLIES: 146 | return "Office Supplies"; 147 | case BranchProductCategory.RELIGIOUS_AND_CEREMONIAL: 148 | return "Religious & Ceremonial"; 149 | case BranchProductCategory.SOFTWARE: 150 | return "Software"; 151 | case BranchProductCategory.SPORTING_GOODS: 152 | return "Sporting Goods"; 153 | case BranchProductCategory.TOYS_AND_GAMES: 154 | return "Toys & Games"; 155 | case BranchProductCategory.VEHICLES_AND_PARTS: 156 | return "Vehicles & Parts"; 157 | } 158 | 159 | return ""; 160 | } 161 | 162 | public static BranchProductCategory parse(this string category) 163 | { 164 | if (category.Equals("Animals & Pet Supplies")) { 165 | return BranchProductCategory.ANIMALS_AND_PET_SUPPLIES; 166 | } 167 | if (category.Equals("Apparel & Accessories")) { 168 | return BranchProductCategory.APPAREL_AND_ACCESSORIES; 169 | } 170 | if (category.Equals("Arts & Entertainment")) { 171 | return BranchProductCategory.ARTS_AND_ENTERTAINMENT; 172 | } 173 | if (category.Equals("Baby & Toddler")) { 174 | return BranchProductCategory.BABY_AND_TODDLER; 175 | } 176 | if (category.Equals("Business & Industrial")) { 177 | return BranchProductCategory.BUSINESS_AND_INDUSTRIAL; 178 | } 179 | if (category.Equals("Cameras & Optics")) { 180 | return BranchProductCategory.CAMERAS_AND_OPTICS; 181 | } 182 | if (category.Equals("Electronics")) { 183 | return BranchProductCategory.ELECTRONICS; 184 | } 185 | if (category.Equals("Food, Beverages & Tobacco")) { 186 | return BranchProductCategory.FOOD_BEVERAGES_AND_TOBACCO; 187 | } 188 | if (category.Equals("Furniture")) { 189 | return BranchProductCategory.FURNITURE; 190 | } 191 | if (category.Equals("Hardware")) { 192 | return BranchProductCategory.HARDWARE; 193 | } 194 | if (category.Equals("Health & Beauty")) { 195 | return BranchProductCategory.HEALTH_AND_BEAUTY; 196 | } 197 | if (category.Equals("Home & Garden")) { 198 | return BranchProductCategory.HOME_AND_GARDEN; 199 | } 200 | if (category.Equals("Luggage & Bags")) { 201 | return BranchProductCategory.LUGGAGE_AND_BAGS; 202 | } 203 | if (category.Equals("Mature")) { 204 | return BranchProductCategory.MATURE; 205 | } 206 | if (category.Equals("Media")) { 207 | return BranchProductCategory.MEDIA; 208 | } 209 | if (category.Equals("Office Supplies")) { 210 | return BranchProductCategory.OFFICE_SUPPLIES; 211 | } 212 | if (category.Equals("Religious & Ceremonial")) { 213 | return BranchProductCategory.RELIGIOUS_AND_CEREMONIAL; 214 | } 215 | if (category.Equals("Software")) { 216 | return BranchProductCategory.SOFTWARE; 217 | } 218 | if (category.Equals("Sporting Goods")) { 219 | return BranchProductCategory.SPORTING_GOODS; 220 | } 221 | if (category.Equals("Toys & Games")) { 222 | return BranchProductCategory.TOYS_AND_GAMES; 223 | } 224 | if (category.Equals("Vehicles & Parts")) { 225 | return BranchProductCategory.VEHICLES_AND_PARTS; 226 | } 227 | 228 | return BranchProductCategory.NONE; 229 | } 230 | } 231 | 232 | public enum BranchQRCodePattern 233 | { 234 | Default, //1 235 | Squares, //2 236 | Circles, //3 237 | Triangles, //4 238 | Pentagons, //5 239 | Hexagons, //6 240 | Octagons //7 241 | } 242 | 243 | public enum BranchQRCodeFinderPattern 244 | { 245 | Square, //1 246 | RoundedSquare, //2 247 | Circle, //3 248 | } 249 | 250 | public enum BranchImageFormat 251 | { 252 | JPEG, //QR code is returned as a JPEG 253 | PNG //QR code is returned as a PNG 254 | } -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Demo/Scripts/BranchDemo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System; 6 | 7 | public class BranchDemo : MonoBehaviour { 8 | 9 | public InputField inputShortLink; 10 | public Text lblSetUserID; 11 | public Text lblLog; 12 | public GameObject mainPanel; 13 | public GameObject rewardsHistoryPanel; 14 | public GameObject logPanel; 15 | public GameObject quitButton; 16 | public RawImage qrCodeRawImage; 17 | 18 | private BranchUniversalObject universalObject = null; 19 | private BranchLinkProperties linkProperties = null; 20 | private BranchQRCode qrCode = null; 21 | private string logString = ""; 22 | 23 | #region Init 24 | 25 | void Awake() { 26 | Application.logMessageReceived += OnLogMessage; 27 | } 28 | 29 | void Start() { 30 | 31 | #if UNITY_IOS 32 | quitButton.SetActive(false); 33 | #endif 34 | 35 | // set debug if need 36 | if (BranchData.Instance.enableLogging) { 37 | Branch.enableLogging(); 38 | } 39 | 40 | // disable tracking of analytics for the user 41 | Branch.setTrackingDisabled(false); 42 | 43 | //init Branch with Dictionary 44 | //Branch.initSession(CallbackWithParams); 45 | 46 | //init Branch with BUO 47 | Branch.initSession(CallbackWithBranchUniversalObject); 48 | } 49 | 50 | public void CallbackWithParams(Dictionary<string, object> parameters, string error) { 51 | if (error != null) { 52 | Debug.Log("Branch Error: " + error); 53 | } 54 | else { 55 | Debug.Log("Branch initialization completed: "); 56 | foreach(string str in parameters.Keys) { 57 | Debug.Log(str + " : " + parameters[str].ToString()); 58 | } 59 | } 60 | } 61 | 62 | public void CallbackWithBranchUniversalObject(BranchUniversalObject universalObject, BranchLinkProperties linkProperties, string error) { 63 | if (error != null) { 64 | Debug.LogError("Branch Error: " + error); 65 | } else { 66 | Debug.Log("Branch initialization completed: "); 67 | 68 | Debug.Log("Universal Object: " + universalObject.ToJsonString()); 69 | Debug.Log("Link Properties: " + linkProperties.ToJsonString()); 70 | } 71 | } 72 | 73 | #endregion 74 | 75 | #region Utils 76 | 77 | private void OnLogMessage(string condition, string stackTrace, LogType type) 78 | { 79 | var typePrefix = type != LogType.Log ? type + ": " : ""; 80 | logString += DateTime.Now.ToLongTimeString() + "> " + typePrefix + condition + "\n"; 81 | } 82 | 83 | #endregion 84 | 85 | #region MainPanel 86 | 87 | public void OnBtn_CreateBranchLink() { 88 | try { 89 | universalObject = new BranchUniversalObject(); 90 | universalObject.canonicalIdentifier = "id12345"; 91 | universalObject.canonicalUrl = "https://branch.io"; 92 | universalObject.title = "id12345 title"; 93 | universalObject.contentDescription = "My awesome piece of content!"; 94 | universalObject.imageUrl = "https://s3-us-west-1.amazonaws.com/branchhost/mosaic_og.png"; 95 | universalObject.contentIndexMode = 0; 96 | universalObject.localIndexMode = 0; 97 | universalObject.expirationDate = new DateTime(2020, 12, 30); 98 | universalObject.keywords.Add("keyword01"); 99 | universalObject.keywords.Add("keyword02"); 100 | 101 | universalObject.metadata.contentSchema = BranchContentSchema.COMMERCE_BUSINESS; 102 | universalObject.metadata.quantity = 100f; 103 | universalObject.metadata.price = 1000f; 104 | universalObject.metadata.currencyType = BranchCurrencyType.USD; 105 | universalObject.metadata.sku = "my_sku"; 106 | universalObject.metadata.productName = "my_product_name"; 107 | universalObject.metadata.productBrand = "my_product_brand"; 108 | universalObject.metadata.productCategory = BranchProductCategory.BUSINESS_AND_INDUSTRIAL; 109 | universalObject.metadata.condition = BranchCondition.EXCELLENT; 110 | universalObject.metadata.productVariant = "my_product_variant"; 111 | 112 | universalObject.metadata.setAddress("my_street", "my_city", "my_region", "my_comuntry", "my_postal_code"); 113 | universalObject.metadata.setLocation(40.0f, 40.0f); 114 | universalObject.metadata.setRating(4.0f, 5.0f, 10); 115 | 116 | universalObject.metadata.AddImageCaption("https://s3-us-west-1.amazonaws.com/branchhost/mosaic_og.png"); 117 | universalObject.metadata.AddCustomMetadata("foo", "bar"); 118 | 119 | 120 | // register a view to add to the index 121 | Branch.registerView(universalObject); 122 | 123 | linkProperties = new BranchLinkProperties(); 124 | linkProperties.tags.Add("tag1"); 125 | linkProperties.tags.Add("tag2"); 126 | linkProperties.feature = "sharing"; 127 | linkProperties.channel = "facebook"; 128 | linkProperties.controlParams.Add("$desktop_url", "http://example.com"); 129 | 130 | Branch.getShortURL(universalObject, linkProperties, (url, error) => { 131 | if (error != null) { 132 | Debug.LogError("Branch.getShortURL failed: " + error); 133 | } else { 134 | Debug.Log("Branch.getShortURL url: " + url); 135 | inputShortLink.text = url; 136 | } 137 | }); 138 | } catch(Exception e) { 139 | Debug.Log(e); 140 | } 141 | } 142 | 143 | public void OnBtn_GenerateQRCode() 144 | { 145 | try 146 | { 147 | universalObject = new BranchUniversalObject(); 148 | universalObject.canonicalIdentifier = "qrcodeid12345"; 149 | linkProperties = new BranchLinkProperties(); 150 | qrCode = new BranchQRCode("#FF0000", "#00FF00", 2, 1024, BranchImageFormat.JPEG, "https://play-lh.googleusercontent.com/gJ22vsKfh-dU592AI9GzI4OX9dkyzYPlsGSyr019dQv6cyAvfuRkUtzl9KJADGdTIlQ"); 151 | Branch.generateQRCode(universalObject, linkProperties, qrCode, (data, error) => 152 | { 153 | if (error != null) 154 | { 155 | Debug.LogError("Branch.generateQRCode failed: " + error); 156 | } 157 | else 158 | { 159 | Debug.Log("QR Code Successfully Generated!"); 160 | byte[] decodedBytes = Convert.FromBase64String(data); 161 | Texture2D texture2D = new Texture2D(1, 1); 162 | texture2D.LoadImage(decodedBytes); 163 | texture2D.Apply(); 164 | qrCodeRawImage.texture = texture2D; 165 | } 166 | }); 167 | } 168 | catch (Exception e) 169 | { 170 | Debug.Log("QR Code Generating Error" + e); 171 | } 172 | } 173 | 174 | public void OnBtn_ValidateSDKIntegration() { 175 | Branch.validate(); 176 | } 177 | 178 | public void OnBtn_SendBuyEvent() { 179 | BranchEvent e = new BranchEvent (BranchEventType.PURCHASE); 180 | 181 | e.SetAlias("my_alias"); 182 | e.SetAffiliation("my_affilation"); 183 | e.SetCoupon("my_coupon"); 184 | e.SetCurrency(BranchCurrencyType.USD); 185 | e.SetTax(10.0f); 186 | e.SetRevenue(100.0f); 187 | e.SetShipping(1000.0f); 188 | e.SetDescription("my_description"); 189 | e.SetSearchQuery("my_search_query"); 190 | 191 | Branch.sendEvent(e); 192 | 193 | } 194 | 195 | public void OnBtn_SetUserID() { 196 | Branch.setIdentity("test_user_10", (parameters, error) => { 197 | if (error != null) { 198 | Debug.LogError("Branch.setIdentity failed: " + error); 199 | lblSetUserID.text = "Set User ID"; 200 | } else { 201 | Debug.Log("Branch.setIdentity install params: " + parameters.ToString()); 202 | lblSetUserID.text = "test_user_10"; 203 | } 204 | }); 205 | } 206 | 207 | public void OnBtn_SimualteLogout() { 208 | Branch.logout(); 209 | lblSetUserID.text = "Set User ID"; 210 | } 211 | 212 | public void OnBtn_SendComplexEvent() { 213 | BranchEvent e = new BranchEvent("MY_COMPLEX_EVENT"); 214 | 215 | e.SetAlias("my_alias"); 216 | e.SetAffiliation("my_affilation"); 217 | e.SetCoupon("my_coupon"); 218 | e.SetCurrency(BranchCurrencyType.USD); 219 | e.SetTax(10.0f); 220 | e.SetRevenue(100.0f); 221 | e.SetShipping(1000.0f); 222 | e.SetDescription("my_description"); 223 | e.SetSearchQuery("my_search_query"); 224 | e.AddCustomData("custom_data_key01", "custom_data_value01"); 225 | e.AddCustomData("custom_data_key02", "custom_data_value02"); 226 | 227 | if (universalObject != null) 228 | e.AddContentItem(universalObject); 229 | 230 | Branch.sendEvent(e); 231 | 232 | } 233 | 234 | public void OnBtn_ShareLink() { 235 | try { 236 | if (universalObject == null) { 237 | universalObject = new BranchUniversalObject(); 238 | universalObject.canonicalIdentifier = "id12345"; 239 | universalObject.canonicalUrl = "https://branch.io"; 240 | universalObject.title = "id12345 title"; 241 | universalObject.contentDescription = "My awesome piece of content!"; 242 | universalObject.imageUrl = "https://s3-us-west-1.amazonaws.com/branchhost/mosaic_og.png"; 243 | universalObject.contentIndexMode = 0; 244 | universalObject.localIndexMode = 0; 245 | universalObject.expirationDate = new DateTime(2020, 12, 30); 246 | universalObject.keywords.Add("keyword01"); 247 | universalObject.keywords.Add("keyword02"); 248 | 249 | universalObject.metadata.contentSchema = BranchContentSchema.COMMERCE_BUSINESS; 250 | universalObject.metadata.quantity = 100f; 251 | universalObject.metadata.price = 1000f; 252 | universalObject.metadata.currencyType = BranchCurrencyType.USD; 253 | universalObject.metadata.sku = "my_sku"; 254 | universalObject.metadata.productName = "my_product_name"; 255 | universalObject.metadata.productBrand = "my_product_brand"; 256 | universalObject.metadata.productCategory = BranchProductCategory.BUSINESS_AND_INDUSTRIAL; 257 | universalObject.metadata.condition = BranchCondition.EXCELLENT; 258 | universalObject.metadata.productVariant = "my_product_variant"; 259 | 260 | universalObject.metadata.setAddress("my_street", "my_city", "my_region", "my_comuntry", "my_postal_code"); 261 | universalObject.metadata.setLocation(40.0f, 40.0f); 262 | universalObject.metadata.setRating(4.0f, 5.0f, 10); 263 | 264 | universalObject.metadata.AddImageCaption("https://s3-us-west-1.amazonaws.com/branchhost/mosaic_og.png"); 265 | universalObject.metadata.AddCustomMetadata("foo", "bar"); 266 | 267 | // register a view to add to the index 268 | Branch.registerView(universalObject); 269 | } 270 | 271 | if (linkProperties == null) { 272 | linkProperties = new BranchLinkProperties(); 273 | linkProperties.tags.Add("tag1"); 274 | linkProperties.tags.Add("tag2"); 275 | linkProperties.feature = "invite"; 276 | linkProperties.channel = "Twitter"; 277 | linkProperties.stage = "2"; 278 | linkProperties.controlParams.Add("$desktop_url", "http://example.com"); 279 | } 280 | 281 | Branch.shareLink(universalObject, linkProperties, "hello there with short url", (parameters, error) => { 282 | 283 | if (error != null) { 284 | Debug.LogError("Branch.shareLink failed: " + error); 285 | } else { 286 | Debug.Log("Branch.shareLink success: "); 287 | 288 | if (parameters != null) { 289 | foreach (string key in parameters.Keys) { 290 | Debug.Log(key + "=" + parameters[key].ToString()); 291 | } 292 | } 293 | } 294 | }); 295 | } catch(Exception e) { 296 | Debug.Log(e); 297 | } 298 | } 299 | 300 | public void OnBtn_ViewFirstReferringParams() { 301 | lblLog.text = Branch.getFirstReferringBranchUniversalObject().ToJsonString() + "\n\n"; 302 | lblLog.text += Branch.getFirstReferringBranchLinkProperties().ToJsonString(); 303 | 304 | logPanel.SetActive(true); 305 | mainPanel.SetActive(false); 306 | } 307 | 308 | public void OnBtn_ViewLatestReferringParams() { 309 | lblLog.text = Branch.getLatestReferringBranchUniversalObject().ToJsonString() + "\n\n"; 310 | lblLog.text += Branch.getLatestReferringBranchLinkProperties().ToJsonString(); 311 | 312 | logPanel.SetActive(true); 313 | mainPanel.SetActive(false); 314 | } 315 | 316 | public void OnBtn_SimulateContentAccess() { 317 | if (universalObject != null) { 318 | Branch.registerView(universalObject); 319 | } 320 | } 321 | 322 | public void OnBtn_RegisterForSpotlight() { 323 | if (universalObject != null) { 324 | universalObject.metadata.AddCustomMetadata("deeplink_text", "This link was generated for Spotlight registration"); 325 | Branch.listOnSpotlight(universalObject); 326 | } 327 | } 328 | 329 | public void OnBtn_LogPanel() { 330 | lblLog.text = logString; 331 | logPanel.SetActive(true); 332 | mainPanel.SetActive(false); 333 | } 334 | 335 | #endregion 336 | 337 | #region RewardsHistoryPanel 338 | 339 | public void OnBtn_RewardsHistoryPanel_Back() { 340 | rewardsHistoryPanel.SetActive(false); 341 | mainPanel.SetActive(true); 342 | } 343 | 344 | #endregion 345 | 346 | #region LogPanel 347 | 348 | public void OnBtn_LogPanel_Back() { 349 | logPanel.SetActive(false); 350 | mainPanel.SetActive(true); 351 | } 352 | 353 | #endregion 354 | 355 | public void OnBtn_Quit() { 356 | Application.Quit (); 357 | } 358 | } 359 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.google.external-dependency-manager": { 4 | "version": "1.2.183", 5 | "depth": 0, 6 | "source": "registry", 7 | "dependencies": {}, 8 | "url": "https://package.openupm.com" 9 | }, 10 | "com.unity.2d.sprite": { 11 | "version": "1.0.0", 12 | "depth": 0, 13 | "source": "builtin", 14 | "dependencies": {} 15 | }, 16 | "com.unity.2d.tilemap": { 17 | "version": "1.0.0", 18 | "depth": 0, 19 | "source": "builtin", 20 | "dependencies": { 21 | "com.unity.modules.tilemap": "1.0.0", 22 | "com.unity.modules.uielements": "1.0.0" 23 | } 24 | }, 25 | "com.unity.ads": { 26 | "version": "4.12.0", 27 | "depth": 0, 28 | "source": "registry", 29 | "dependencies": { 30 | "com.unity.ugui": "1.0.0" 31 | }, 32 | "url": "https://packages.unity.com" 33 | }, 34 | "com.unity.ai.navigation": { 35 | "version": "2.0.5", 36 | "depth": 0, 37 | "source": "registry", 38 | "dependencies": { 39 | "com.unity.modules.ai": "1.0.0" 40 | }, 41 | "url": "https://packages.unity.com" 42 | }, 43 | "com.unity.analytics": { 44 | "version": "3.8.1", 45 | "depth": 0, 46 | "source": "registry", 47 | "dependencies": { 48 | "com.unity.ugui": "1.0.0", 49 | "com.unity.services.analytics": "1.0.4" 50 | }, 51 | "url": "https://packages.unity.com" 52 | }, 53 | "com.unity.collab-proxy": { 54 | "version": "2.6.0", 55 | "depth": 0, 56 | "source": "registry", 57 | "dependencies": {}, 58 | "url": "https://packages.unity.com" 59 | }, 60 | "com.unity.ext.nunit": { 61 | "version": "2.0.5", 62 | "depth": 1, 63 | "source": "registry", 64 | "dependencies": {}, 65 | "url": "https://packages.unity.com" 66 | }, 67 | "com.unity.ide.rider": { 68 | "version": "3.0.34", 69 | "depth": 0, 70 | "source": "registry", 71 | "dependencies": { 72 | "com.unity.ext.nunit": "1.0.6" 73 | }, 74 | "url": "https://packages.unity.com" 75 | }, 76 | "com.unity.ide.visualstudio": { 77 | "version": "2.0.22", 78 | "depth": 0, 79 | "source": "registry", 80 | "dependencies": { 81 | "com.unity.test-framework": "1.1.9" 82 | }, 83 | "url": "https://packages.unity.com" 84 | }, 85 | "com.unity.multiplayer.center": { 86 | "version": "1.0.0", 87 | "depth": 0, 88 | "source": "builtin", 89 | "dependencies": { 90 | "com.unity.modules.uielements": "1.0.0" 91 | } 92 | }, 93 | "com.unity.nuget.newtonsoft-json": { 94 | "version": "3.2.1", 95 | "depth": 2, 96 | "source": "registry", 97 | "dependencies": {}, 98 | "url": "https://packages.unity.com" 99 | }, 100 | "com.unity.purchasing": { 101 | "version": "4.12.2", 102 | "depth": 0, 103 | "source": "registry", 104 | "dependencies": { 105 | "com.unity.ugui": "1.0.0", 106 | "com.unity.services.core": "1.12.5", 107 | "com.unity.modules.androidjni": "1.0.0", 108 | "com.unity.modules.jsonserialize": "1.0.0", 109 | "com.unity.modules.unitywebrequest": "1.0.0" 110 | }, 111 | "url": "https://packages.unity.com" 112 | }, 113 | "com.unity.services.analytics": { 114 | "version": "6.0.1", 115 | "depth": 1, 116 | "source": "registry", 117 | "dependencies": { 118 | "com.unity.ugui": "1.0.0", 119 | "com.unity.services.core": "1.12.4", 120 | "com.unity.modules.jsonserialize": "1.0.0" 121 | }, 122 | "url": "https://packages.unity.com" 123 | }, 124 | "com.unity.services.core": { 125 | "version": "1.14.0", 126 | "depth": 1, 127 | "source": "registry", 128 | "dependencies": { 129 | "com.unity.modules.androidjni": "1.0.0", 130 | "com.unity.nuget.newtonsoft-json": "3.2.1", 131 | "com.unity.modules.unitywebrequest": "1.0.0" 132 | }, 133 | "url": "https://packages.unity.com" 134 | }, 135 | "com.unity.test-framework": { 136 | "version": "1.4.5", 137 | "depth": 0, 138 | "source": "registry", 139 | "dependencies": { 140 | "com.unity.ext.nunit": "2.0.3", 141 | "com.unity.modules.imgui": "1.0.0", 142 | "com.unity.modules.jsonserialize": "1.0.0" 143 | }, 144 | "url": "https://packages.unity.com" 145 | }, 146 | "com.unity.timeline": { 147 | "version": "1.8.7", 148 | "depth": 0, 149 | "source": "registry", 150 | "dependencies": { 151 | "com.unity.modules.audio": "1.0.0", 152 | "com.unity.modules.director": "1.0.0", 153 | "com.unity.modules.animation": "1.0.0", 154 | "com.unity.modules.particlesystem": "1.0.0" 155 | }, 156 | "url": "https://packages.unity.com" 157 | }, 158 | "com.unity.ugui": { 159 | "version": "2.0.0", 160 | "depth": 0, 161 | "source": "builtin", 162 | "dependencies": { 163 | "com.unity.modules.ui": "1.0.0", 164 | "com.unity.modules.imgui": "1.0.0" 165 | } 166 | }, 167 | "com.unity.xr.legacyinputhelpers": { 168 | "version": "2.1.11", 169 | "depth": 0, 170 | "source": "registry", 171 | "dependencies": { 172 | "com.unity.modules.vr": "1.0.0", 173 | "com.unity.modules.xr": "1.0.0" 174 | }, 175 | "url": "https://packages.unity.com" 176 | }, 177 | "com.unity.modules.accessibility": { 178 | "version": "1.0.0", 179 | "depth": 0, 180 | "source": "builtin", 181 | "dependencies": {} 182 | }, 183 | "com.unity.modules.ai": { 184 | "version": "1.0.0", 185 | "depth": 0, 186 | "source": "builtin", 187 | "dependencies": {} 188 | }, 189 | "com.unity.modules.androidjni": { 190 | "version": "1.0.0", 191 | "depth": 0, 192 | "source": "builtin", 193 | "dependencies": {} 194 | }, 195 | "com.unity.modules.animation": { 196 | "version": "1.0.0", 197 | "depth": 0, 198 | "source": "builtin", 199 | "dependencies": {} 200 | }, 201 | "com.unity.modules.assetbundle": { 202 | "version": "1.0.0", 203 | "depth": 0, 204 | "source": "builtin", 205 | "dependencies": {} 206 | }, 207 | "com.unity.modules.audio": { 208 | "version": "1.0.0", 209 | "depth": 0, 210 | "source": "builtin", 211 | "dependencies": {} 212 | }, 213 | "com.unity.modules.cloth": { 214 | "version": "1.0.0", 215 | "depth": 0, 216 | "source": "builtin", 217 | "dependencies": { 218 | "com.unity.modules.physics": "1.0.0" 219 | } 220 | }, 221 | "com.unity.modules.director": { 222 | "version": "1.0.0", 223 | "depth": 0, 224 | "source": "builtin", 225 | "dependencies": { 226 | "com.unity.modules.audio": "1.0.0", 227 | "com.unity.modules.animation": "1.0.0" 228 | } 229 | }, 230 | "com.unity.modules.hierarchycore": { 231 | "version": "1.0.0", 232 | "depth": 1, 233 | "source": "builtin", 234 | "dependencies": {} 235 | }, 236 | "com.unity.modules.imageconversion": { 237 | "version": "1.0.0", 238 | "depth": 0, 239 | "source": "builtin", 240 | "dependencies": {} 241 | }, 242 | "com.unity.modules.imgui": { 243 | "version": "1.0.0", 244 | "depth": 0, 245 | "source": "builtin", 246 | "dependencies": {} 247 | }, 248 | "com.unity.modules.jsonserialize": { 249 | "version": "1.0.0", 250 | "depth": 0, 251 | "source": "builtin", 252 | "dependencies": {} 253 | }, 254 | "com.unity.modules.particlesystem": { 255 | "version": "1.0.0", 256 | "depth": 0, 257 | "source": "builtin", 258 | "dependencies": {} 259 | }, 260 | "com.unity.modules.physics": { 261 | "version": "1.0.0", 262 | "depth": 0, 263 | "source": "builtin", 264 | "dependencies": {} 265 | }, 266 | "com.unity.modules.physics2d": { 267 | "version": "1.0.0", 268 | "depth": 0, 269 | "source": "builtin", 270 | "dependencies": {} 271 | }, 272 | "com.unity.modules.screencapture": { 273 | "version": "1.0.0", 274 | "depth": 0, 275 | "source": "builtin", 276 | "dependencies": { 277 | "com.unity.modules.imageconversion": "1.0.0" 278 | } 279 | }, 280 | "com.unity.modules.subsystems": { 281 | "version": "1.0.0", 282 | "depth": 1, 283 | "source": "builtin", 284 | "dependencies": { 285 | "com.unity.modules.jsonserialize": "1.0.0" 286 | } 287 | }, 288 | "com.unity.modules.terrain": { 289 | "version": "1.0.0", 290 | "depth": 0, 291 | "source": "builtin", 292 | "dependencies": {} 293 | }, 294 | "com.unity.modules.terrainphysics": { 295 | "version": "1.0.0", 296 | "depth": 0, 297 | "source": "builtin", 298 | "dependencies": { 299 | "com.unity.modules.physics": "1.0.0", 300 | "com.unity.modules.terrain": "1.0.0" 301 | } 302 | }, 303 | "com.unity.modules.tilemap": { 304 | "version": "1.0.0", 305 | "depth": 0, 306 | "source": "builtin", 307 | "dependencies": { 308 | "com.unity.modules.physics2d": "1.0.0" 309 | } 310 | }, 311 | "com.unity.modules.ui": { 312 | "version": "1.0.0", 313 | "depth": 0, 314 | "source": "builtin", 315 | "dependencies": {} 316 | }, 317 | "com.unity.modules.uielements": { 318 | "version": "1.0.0", 319 | "depth": 0, 320 | "source": "builtin", 321 | "dependencies": { 322 | "com.unity.modules.ui": "1.0.0", 323 | "com.unity.modules.imgui": "1.0.0", 324 | "com.unity.modules.jsonserialize": "1.0.0", 325 | "com.unity.modules.hierarchycore": "1.0.0" 326 | } 327 | }, 328 | "com.unity.modules.umbra": { 329 | "version": "1.0.0", 330 | "depth": 0, 331 | "source": "builtin", 332 | "dependencies": {} 333 | }, 334 | "com.unity.modules.unityanalytics": { 335 | "version": "1.0.0", 336 | "depth": 0, 337 | "source": "builtin", 338 | "dependencies": { 339 | "com.unity.modules.unitywebrequest": "1.0.0", 340 | "com.unity.modules.jsonserialize": "1.0.0" 341 | } 342 | }, 343 | "com.unity.modules.unitywebrequest": { 344 | "version": "1.0.0", 345 | "depth": 0, 346 | "source": "builtin", 347 | "dependencies": {} 348 | }, 349 | "com.unity.modules.unitywebrequestassetbundle": { 350 | "version": "1.0.0", 351 | "depth": 0, 352 | "source": "builtin", 353 | "dependencies": { 354 | "com.unity.modules.assetbundle": "1.0.0", 355 | "com.unity.modules.unitywebrequest": "1.0.0" 356 | } 357 | }, 358 | "com.unity.modules.unitywebrequestaudio": { 359 | "version": "1.0.0", 360 | "depth": 0, 361 | "source": "builtin", 362 | "dependencies": { 363 | "com.unity.modules.unitywebrequest": "1.0.0", 364 | "com.unity.modules.audio": "1.0.0" 365 | } 366 | }, 367 | "com.unity.modules.unitywebrequesttexture": { 368 | "version": "1.0.0", 369 | "depth": 0, 370 | "source": "builtin", 371 | "dependencies": { 372 | "com.unity.modules.unitywebrequest": "1.0.0", 373 | "com.unity.modules.imageconversion": "1.0.0" 374 | } 375 | }, 376 | "com.unity.modules.unitywebrequestwww": { 377 | "version": "1.0.0", 378 | "depth": 0, 379 | "source": "builtin", 380 | "dependencies": { 381 | "com.unity.modules.unitywebrequest": "1.0.0", 382 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 383 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 384 | "com.unity.modules.audio": "1.0.0", 385 | "com.unity.modules.assetbundle": "1.0.0", 386 | "com.unity.modules.imageconversion": "1.0.0" 387 | } 388 | }, 389 | "com.unity.modules.vehicles": { 390 | "version": "1.0.0", 391 | "depth": 0, 392 | "source": "builtin", 393 | "dependencies": { 394 | "com.unity.modules.physics": "1.0.0" 395 | } 396 | }, 397 | "com.unity.modules.video": { 398 | "version": "1.0.0", 399 | "depth": 0, 400 | "source": "builtin", 401 | "dependencies": { 402 | "com.unity.modules.audio": "1.0.0", 403 | "com.unity.modules.ui": "1.0.0", 404 | "com.unity.modules.unitywebrequest": "1.0.0" 405 | } 406 | }, 407 | "com.unity.modules.vr": { 408 | "version": "1.0.0", 409 | "depth": 0, 410 | "source": "builtin", 411 | "dependencies": { 412 | "com.unity.modules.jsonserialize": "1.0.0", 413 | "com.unity.modules.physics": "1.0.0", 414 | "com.unity.modules.xr": "1.0.0" 415 | } 416 | }, 417 | "com.unity.modules.wind": { 418 | "version": "1.0.0", 419 | "depth": 0, 420 | "source": "builtin", 421 | "dependencies": {} 422 | }, 423 | "com.unity.modules.xr": { 424 | "version": "1.0.0", 425 | "depth": 0, 426 | "source": "builtin", 427 | "dependencies": { 428 | "com.unity.modules.physics": "1.0.0", 429 | "com.unity.modules.jsonserialize": "1.0.0", 430 | "com.unity.modules.subsystems": "1.0.0" 431 | } 432 | } 433 | } 434 | } 435 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/BranchContentMetadata.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class BranchContentMetadata { 7 | 8 | private Dictionary<string, object> metadata = new Dictionary<string, object>(); 9 | 10 | #region Properties 11 | 12 | // Schema for the qualifying content item. Please see {@link BranchContentSchema} 13 | public BranchContentSchema contentSchema { 14 | get { 15 | if (metadata.ContainsKey ("$content_schema")) 16 | return (BranchContentSchema)Enum.Parse (typeof(BranchContentSchema), metadata ["$content_schema"].ToString ()); 17 | else 18 | return BranchContentSchema.NONE; 19 | } 20 | set { 21 | AddData ("$content_schema", value.ToString()); 22 | } 23 | } 24 | 25 | // Quantity of the thing associated with the qualifying content item 26 | public float quantity { 27 | get { 28 | if (metadata.ContainsKey ("$quantity")) 29 | return (float)metadata ["$quantity"]; 30 | else 31 | return 0.0f; 32 | } 33 | set { 34 | AddData ("$quantity", value); 35 | } 36 | } 37 | 38 | // Any price associated with the qualifying content item 39 | public float price { 40 | get { 41 | if (metadata.ContainsKey ("$price")) 42 | return (float)metadata ["$price"]; 43 | else 44 | return 0.0f; 45 | } 46 | set { 47 | AddData ("$price", value); 48 | } 49 | } 50 | 51 | // Currency type associated with the price 52 | public BranchCurrencyType currencyType { 53 | get { 54 | if (metadata.ContainsKey ("$currency")) 55 | return (BranchCurrencyType)Enum.Parse (typeof(BranchCurrencyType), metadata ["$currency"].ToString ()); 56 | else 57 | return BranchCurrencyType.NONE; 58 | } 59 | set { 60 | AddData ("$currency", value.ToString()); 61 | } 62 | } 63 | 64 | // Holds any associated store keeping unit 65 | public string sku { 66 | get { 67 | if (metadata.ContainsKey ("$sku")) 68 | return metadata ["$sku"].ToString (); 69 | else 70 | return ""; 71 | } 72 | set { 73 | AddData ("$sku", value.ToString()); 74 | } 75 | } 76 | 77 | // Name of any product specified by this metadata 78 | public string productName { 79 | get { 80 | if (metadata.ContainsKey ("$product_name")) 81 | return metadata ["$product_name"].ToString (); 82 | else 83 | return ""; 84 | } 85 | set { 86 | AddData ("$product_name", value.ToString()); 87 | } 88 | } 89 | 90 | // Any brand name associated with this metadata 91 | public string productBrand { 92 | get { 93 | if (metadata.ContainsKey ("$product_brand")) 94 | return metadata ["$product_brand"].ToString (); 95 | else 96 | return ""; 97 | } 98 | set { 99 | AddData ("$product_brand", value.ToString()); 100 | } 101 | } 102 | 103 | // Category of product if this metadata is for a product 104 | // Value should be one of the enumeration from BranchProductCategory 105 | public BranchProductCategory productCategory { 106 | get { 107 | if (metadata.ContainsKey ("$product_category")) 108 | return metadata ["$product_category"].ToString ().parse(); 109 | else 110 | return BranchProductCategory.NONE; 111 | } 112 | set { 113 | AddData ("$product_category", value.toString()); 114 | } 115 | } 116 | 117 | // Condition of the product item. Value is one of the enum constants from BranchCondition 118 | public BranchCondition condition { 119 | get { 120 | if (metadata.ContainsKey ("$condition")) 121 | return (BranchCondition)Enum.Parse (typeof(BranchCondition), metadata ["$condition"].ToString ()); 122 | else 123 | return BranchCondition.NONE; 124 | } 125 | set { 126 | AddData ("$condition", value.ToString()); 127 | } 128 | } 129 | 130 | // Variant of product if this metadata is for a product 131 | public string productVariant { 132 | get { 133 | if (metadata.ContainsKey ("$product_variant")) 134 | return metadata ["$product_variant"].ToString (); 135 | else 136 | return ""; 137 | } 138 | set { 139 | AddData ("$product_variant", value.ToString()); 140 | } 141 | } 142 | 143 | // Average rating for the qualifying content item 144 | public float ratingAverage { 145 | get { 146 | if (metadata.ContainsKey ("$rating_average")) 147 | return (float)metadata ["$rating_average"]; 148 | else 149 | return 0.0f; 150 | } 151 | set { 152 | AddData ("$rating_average", value); 153 | } 154 | } 155 | 156 | // Total number of ratings for the qualifying content item 157 | public int ratingCount { 158 | get { 159 | if (metadata.ContainsKey ("$rating_count")) 160 | return (int)metadata ["$rating_count"]; 161 | else 162 | return 0; 163 | } 164 | set { 165 | AddData ("$rating_count", value); 166 | } 167 | } 168 | 169 | // Maximum ratings for the qualifying content item 170 | public float ratingMax { 171 | get { 172 | if (metadata.ContainsKey ("$rating_max")) 173 | return (float)metadata ["$rating_max"]; 174 | else 175 | return 0.0f; 176 | } 177 | set { 178 | AddData ("$rating_max", value); 179 | } 180 | } 181 | 182 | // Street address associated with the qualifying content item 183 | public string addressStreet { 184 | get { 185 | if (metadata.ContainsKey ("$address_street")) 186 | return metadata ["$address_street"].ToString (); 187 | else 188 | return ""; 189 | } 190 | set { 191 | AddData ("$address_street", value.ToString()); 192 | } 193 | } 194 | 195 | // City name associated with the qualifying content item 196 | public string addressCity { 197 | get { 198 | if (metadata.ContainsKey ("$address_city")) 199 | return metadata ["$address_city"].ToString (); 200 | else 201 | return ""; 202 | } 203 | set { 204 | AddData ("$address_city", value.ToString()); 205 | } 206 | } 207 | 208 | // Region or province name associated with the qualifying content item 209 | public string addressRegion { 210 | get { 211 | if (metadata.ContainsKey ("$address_region")) 212 | return metadata ["$address_region"].ToString (); 213 | else 214 | return ""; 215 | } 216 | set { 217 | AddData ("$address_region", value.ToString()); 218 | } 219 | } 220 | 221 | // Country name associated with the qualifying content item 222 | public string addressCountry { 223 | get { 224 | if (metadata.ContainsKey ("$address_country")) 225 | return metadata ["$address_country"].ToString (); 226 | else 227 | return ""; 228 | } 229 | set { 230 | AddData ("$address_country", value.ToString()); 231 | } 232 | } 233 | 234 | // Postal code associated with the qualifying content item 235 | public string addressPostalCode { 236 | get { 237 | if (metadata.ContainsKey ("$address_postal_code")) 238 | return metadata ["$address_postal_code"].ToString (); 239 | else 240 | return ""; 241 | } 242 | set { 243 | AddData ("$address_postal_code", value.ToString()); 244 | } 245 | } 246 | 247 | // Latitude value associated with the qualifying content item 248 | public float latitude { 249 | get { 250 | if (metadata.ContainsKey ("$latitude")) 251 | return (float)metadata ["$latitude"]; 252 | else 253 | return 0.0f; 254 | } 255 | set { 256 | AddData ("$latitude", value); 257 | } 258 | } 259 | 260 | // Longitude value associated with the qualifying content item 261 | public float longitude { 262 | get { 263 | if (metadata.ContainsKey ("$longitude")) 264 | return (float)metadata ["$longitude"]; 265 | else 266 | return 0.0f; 267 | } 268 | set { 269 | AddData ("$longitude", value); 270 | } 271 | } 272 | 273 | 274 | // Image captions associated with the qualifying content item 275 | private List<string> imageCaptions = new List<string>(); 276 | 277 | public void AddImageCaption(string imageCaption) { 278 | imageCaptions.Add (imageCaption); 279 | } 280 | 281 | public List<string> GetImageCaptions() { 282 | return imageCaptions; 283 | } 284 | 285 | // Custom metadata associated with the qualifying content item 286 | private Dictionary<string, string> customMetadata = new Dictionary<string, string>(); 287 | 288 | public void AddCustomMetadata(string key, string value) { 289 | if (!customMetadata.ContainsKey(key)) { 290 | customMetadata.Add (key, value); 291 | } 292 | else{ 293 | customMetadata [key] = value; 294 | } 295 | } 296 | 297 | public Dictionary<string, string> GetCustomMetadata() { 298 | return customMetadata; 299 | } 300 | 301 | #endregion 302 | 303 | public void setAddress(string street, string city, string region, string country, string postalCode) { 304 | this.addressStreet = street; 305 | this.addressCity = city; 306 | this.addressRegion = region; 307 | this.addressCountry = country; 308 | this.addressPostalCode = postalCode; 309 | } 310 | 311 | public void setLocation(float latitude, float longitude) { 312 | this.latitude = latitude; 313 | this.longitude = longitude; 314 | } 315 | 316 | public void setRating(float averageRating, float maximumRating, int ratingCount) { 317 | this.ratingAverage = averageRating; 318 | this.ratingMax = maximumRating; 319 | this.ratingCount = ratingCount; 320 | } 321 | 322 | private void AddData(string key, object value) { 323 | if (!metadata.ContainsKey(key)) { 324 | metadata.Add (key, value); 325 | } 326 | else{ 327 | metadata [key] = value; 328 | } 329 | } 330 | 331 | public void loadFromJson(string json) { 332 | if (string.IsNullOrEmpty(json)) 333 | return; 334 | 335 | var data = BranchThirdParty_MiniJSON.Json.Deserialize(json) as Dictionary<string, object>; 336 | loadFromDictionary(data); 337 | } 338 | 339 | public void loadFromDictionary(Dictionary<string, object> data) { 340 | if (data == null) 341 | return; 342 | 343 | if (data.ContainsKey("$content_schema") && data["$content_schema"] != null) { 344 | contentSchema = (BranchContentSchema)Enum.Parse (typeof(BranchContentSchema), data["$content_schema"].ToString()); 345 | data.Remove ("$content_schema"); 346 | } 347 | if (data.ContainsKey("$quantity") && data["$quantity"] != null) { 348 | quantity = Convert.ToSingle(data["$quantity"]); 349 | data.Remove ("$quantity"); 350 | } 351 | if (data.ContainsKey("$price") && data["$price"] != null) { 352 | price = Convert.ToSingle(data["$price"]); 353 | data.Remove ("$price"); 354 | } 355 | if (data.ContainsKey("$currency") && data["$currency"] != null) { 356 | currencyType = (BranchCurrencyType)Enum.Parse (typeof(BranchCurrencyType), data["$currency"].ToString()); 357 | data.Remove ("$currency"); 358 | } 359 | if (data.ContainsKey("$sku") && data["$sku"] != null) { 360 | sku = data["$sku"].ToString(); 361 | data.Remove ("$sku"); 362 | } 363 | if (data.ContainsKey("$product_name") && data["$product_name"] != null) { 364 | productName = data["$product_name"].ToString(); 365 | data.Remove ("$product_name"); 366 | } 367 | if (data.ContainsKey("$product_brand") && data["$product_brand"] != null) { 368 | productBrand = data["$product_brand"].ToString(); 369 | data.Remove ("$product_brand"); 370 | } 371 | if (data.ContainsKey("$product_category") && data["$product_category"] != null) { 372 | productCategory = data["$product_category"].ToString().parse(); 373 | data.Remove ("$product_category"); 374 | } 375 | if (data.ContainsKey("$condition") && data["$condition"] != null) { 376 | condition = (BranchCondition)Enum.Parse (typeof(BranchCondition), data["$condition"].ToString()); 377 | data.Remove ("$condition"); 378 | } 379 | if (data.ContainsKey("$product_variant") && data["$product_variant"] != null) { 380 | productVariant = data["$product_variant"].ToString(); 381 | data.Remove ("$product_variant"); 382 | } 383 | if (data.ContainsKey("$rating_average") && data["$rating_average"] != null) { 384 | ratingAverage = Convert.ToSingle(data["$rating_average"]); 385 | data.Remove ("$rating_average"); 386 | } 387 | if (data.ContainsKey("$rating_count") && data["$rating_count"] != null) { 388 | ratingCount = Convert.ToInt32(data["$rating_count"]); 389 | data.Remove ("$rating_count"); 390 | } 391 | if (data.ContainsKey("$rating_max") && data["$rating_max"] != null) { 392 | ratingMax = Convert.ToSingle(data["$rating_max"]); 393 | data.Remove ("$rating_max"); 394 | } 395 | if (data.ContainsKey("$address_street") && data["$address_street"] != null) { 396 | addressStreet = data["$address_street"].ToString(); 397 | data.Remove ("$address_street"); 398 | } 399 | if (data.ContainsKey("$address_city") && data["$address_city"] != null) { 400 | addressCity = data["$address_city"].ToString(); 401 | data.Remove ("$address_city"); 402 | } 403 | if (data.ContainsKey("$address_region") && data["$address_region"] != null) { 404 | addressRegion = data["$address_region"].ToString(); 405 | data.Remove ("$address_region"); 406 | } 407 | if (data.ContainsKey("$address_country") && data["$address_country"] != null) { 408 | addressCountry = data["$address_country"].ToString(); 409 | data.Remove ("$address_country"); 410 | } 411 | if (data.ContainsKey("$address_postal_code") && data["$address_postal_code"] != null) { 412 | addressPostalCode = data["$address_postal_code"].ToString(); 413 | data.Remove ("$address_postal_code"); 414 | } 415 | if (data.ContainsKey("$latitude") && data["$latitude"] != null) { 416 | latitude = Convert.ToSingle(data["$latitude"]); 417 | data.Remove ("$latitude"); 418 | } 419 | if (data.ContainsKey("$longitude") && data["$longitude"] != null) { 420 | longitude = Convert.ToSingle(data["$longitude"]); 421 | data.Remove ("$longitude"); 422 | } 423 | 424 | if (data.ContainsKey ("$image_captions")) { 425 | if (data ["$image_captions"] != null) { 426 | List<object> imageCaptionsTemp = data ["$image_captions"] as List<object>; 427 | 428 | if (imageCaptionsTemp != null) { 429 | foreach (object obj in imageCaptionsTemp) { 430 | imageCaptions.Add (obj.ToString ()); 431 | } 432 | } 433 | 434 | data.Remove ("$image_captions"); 435 | } 436 | } 437 | 438 | foreach (string key in data.Keys) { 439 | customMetadata.Add (key, data [key].ToString ()); 440 | } 441 | } 442 | 443 | 444 | public string ToJsonString() { 445 | var data = new Dictionary<string, object>(metadata); 446 | 447 | if (imageCaptions.Count > 0) { 448 | data.Add ("$image_captions", imageCaptions); 449 | } 450 | 451 | if (customMetadata.Count > 0) { 452 | foreach (string key in customMetadata.Keys) { 453 | data.Add (key, customMetadata[key]); 454 | } 455 | } 456 | 457 | return BranchThirdParty_MiniJSON.Json.Serialize(data); 458 | } 459 | } 460 | -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | Branch Unity SDK change log 2 | 3 | - 2.0.0 4 | * External Dependency Manager for Unity (EDM4U) is no longer bundled with the Branch SDK. Clients will need to install it separately. 5 | * Update iOS SDK to 3.4.3 6 | * Update Android SDK to 5.12.0 7 | 8 | - 1.0.0 9 | * Update iOS SDK to 2.1.0 10 | * Update Android SDK to 5.3.0 11 | * Remove old Apple Search Ads methods, these APIs are being shutdown by Apple. 12 | * Remove deprecated userCompletedAction methods 13 | * Remove deprecated credit related methods. Backend has been shutdown. 14 | * Add support for deferred initialization. This will force the underlying Android/iOS code to wait for the C# code to register a callback. 15 | * Add /Assets/StreamedAssets/branch.json 16 | * Set `deferInitForPluginRuntime` to true 17 | * Switch to semantic versioning 18 | 19 | - 0.6.7 20 | * Updating to iOS SDK 1.39.2 21 | * Updating to Android SDK 5.0.7 22 | * Add FB partner parameters API. Known issue with Android not respecting this value on install and open. It does support events. 23 | 24 | - 0.6.6 25 | * Updating Branch to iOS version 0.35.0 26 | 27 | - 0.6.5 28 | * Supporting field 'custom event alias' 29 | 30 | - 0.6.4 31 | * Adding 'play-services-ads:16.0.0' dependencies 32 | * Adding PlayServicesResolver plugin 33 | 34 | - 0.6.3 35 | * Fixing wrong Unity target for Unity 2019.x 36 | 37 | - 0.6.2 38 | * Supporting Unity3d 2019.x 39 | * Fixing Branch prefab 40 | * Fixing plugin type value 41 | * Setting plugin version value from one place 42 | 43 | - 0.6.1 44 | * Updating Branch to iOS version 0.31.4 45 | 46 | - 0.6.0 47 | * Updating Branch to Android version 4.3.2 48 | * Fix missing refrring params 49 | 50 | - 0.5.15 51 | * Updating Branch to Android version 4.2.1 and iOS version 0.31.3 52 | 53 | - 0.5.14 54 | * Updating Branch to iOS version 0.31.0 55 | 56 | - 0.5.13 57 | * Updating Branch to Android version 4.2.0 and iOS version 0.30.1 58 | * Deleting method `initSession()` in `Branch` class 59 | * Deleting method `initSession(bool isReferrable)` in `Branch` class 60 | * Deleting method `initSession(bool isReferrable, BranchCallbackWithParams callback)` in `Branch` classcallback)` instead 61 | 62 | - 0.5.12 63 | * Fixed #160 - Link property alias not being added to custom link generated 64 | 65 | - 0.5.11 66 | * Updating Branch to Android version 4.1.0 and iOS version 0.29.1 67 | 68 | - 0.5.10 69 | * Updating Branch to IOS version 0.28.1 70 | * Adding method `SetAlias(string alias)` in `BranchEvent` class 71 | * Deleting method `setAppleSearchAdsDebugMode()` 72 | 73 | - 0.5.9 74 | * Updating Branch to Android version 4.0.0 75 | 76 | - 0.5.8 77 | * Add domain entitlements to XCode project 78 | 79 | - 0.5.7 80 | * Updating Branch to Android version 3.2.0 and iOS version 0.27.0 81 | 82 | - 0.5.6 83 | * Ading default expiration date to avoid issues with events on ios 84 | 85 | - 0.5.5 86 | * Fixing #144 Branch.shareLink callback is not always called on Android 87 | * Disabling proguard for BranchAndroidWrapper.jar 88 | 89 | - 0.5.4 90 | * Updating Branch to iOS version 0.25.11 91 | * Fixing several issues 92 | * Adding possibility to omit URI Scheme, Android Prefix, App link domains 93 | * Adding MultiDex support solution 94 | 95 | - 0.5.3 96 | * Updating Branch to Android version 3.0.3 and iOS version 0.25.10 97 | 98 | - 0.5.2 99 | * Adding method SetAppleSearchAdsDebugMode (for ios only) 100 | * Adding method DelayInitToCheckForSearchAds (for ios only) 101 | 102 | - 0.5.1 103 | * Updating Branch to Android version 3.0.1 and iOS version 0.25.8 104 | * Changing the api.branch.io endpoint to api2.branch.io 105 | * Android Min SDK version is now 16. 106 | 107 | - 0.4.12 108 | * Updating Branch to Android version 2.19.5 and iOS version 0.25.6 109 | 110 | - 0.4.11 111 | * Updating Branch to Android version 2.19.3 and iOS version 0.25.3 112 | 113 | - 0.4.10 114 | * Updating Branch to Android version 2.19.0 and iOS version 0.25.2 115 | * Fixes for Unity 2018 116 | 117 | - 0.4.9 118 | * Updating Branch to Android version 2.18.1 119 | * Adding method for disable/enable of tracking of analytics for the user 120 | * Updating readme file 121 | 122 | - 0.4.8 123 | * Updating Branch to Android version 2.18.0 and iOS version 0.25.0 124 | 125 | - 0.4.7 126 | * Updating Branch to Android version 2.17.0 and iOS version 0.24.1 127 | 128 | - 0.4.6 129 | * Updating Branch to Android version 2.16.0 and iOS version 0.23.2 130 | 131 | - 0.4.5 132 | * Updating Branch to Android version 2.15.0 and iOS version 0.22.5 133 | 134 | - 0.4.4 135 | * deleting wrong comments 136 | 137 | - 0.4.3 138 | * deleting unused permissions in android manifest 139 | 140 | - 0.4.2 141 | * Fixing BranchiOSWrapper.mm 142 | 143 | - 0.4.1 144 | * Updating Branch to Android version 2.14.4 and iOS version 0.22.4 145 | * Updating BranchUniversalObject 146 | * Adding new class for metadata (BranchContentMetadata) 147 | * Adding API for sending branch events 148 | * Updating Readme 149 | 150 | - v0.3.27 151 | * Updating Branch to iOS version 0.20.3 152 | * Adding method `setRequestMetadata(string key, string val)` 153 | 154 | - v0.3.26 155 | * Updating Branch to Android version 2.13.1 156 | 157 | - v0.3.25 158 | * Updating Branch to Android version 2.12.2 and iOS version 0.20.2 159 | 160 | - v0.3.24 161 | * @import changed to #import to fix issues "@import when modules are disabled" for Objectvie C and C++ 162 | 163 | - v0.3.23 164 | * Updating Branch to iOS version 0.19.5 165 | 166 | - v0.3.22 167 | * Updating Branch to Android version 2.12.1 168 | * Fix for iOS version 169 | 170 | - v0.3.21 171 | * Updating Branch to Android version 2.12.0 and iOS version 0.18.8 172 | * Fix for BranchThirdParty.jar 173 | 174 | - v0.3.20 175 | * Fix for Unity 2017 176 | 177 | - v0.3.19 178 | * Updating Branch to Android version 2.11.1 and iOS version 0.17.7 179 | 180 | - v0.3.18 181 | * Updating Branch to iOS version 0.17.6 182 | * Updated algorithm for android manifest updating 183 | 184 | - v0.3.17 185 | * Updating Branch to Android version 2.10.3 and iOS version 0.17.5 186 | 187 | - v0.3.16 188 | * Updating Branch to Android version 2.10.2 189 | 190 | - v0.3.15 191 | * Updating Branch to Android version 2.8.0 and iOS version 0.15.3 192 | * Adding cononicalUrl for BranchUniversalObject 193 | 194 | - v0.3.14 195 | * Updating Branch to Android version 2.6.1 and iOS version 0.14.12 196 | * Fixing RewardsHistoryPanel 197 | 198 | - v0.3.13 199 | * Updating Branch to Android version 2.6.0 200 | * Fixing AndroidThirdParty 201 | * Updating BranchThirdParty.jar for Fabric solution 202 | 203 | - v0.3.12 204 | * Updating Branch to Android version 2.5.9 and iOS version 0.13.5 205 | * Adding strings.xml to AndroidWrapperProject and AndroidThirdParty for avoiding of building error 206 | 207 | - v0.3.11 208 | * Updating Branch to Android version 2.5.7 and iOS version 0.12.27 209 | 210 | - v0.3.10 211 | * Updating Branch to Android version 2.5.5 and iOS version 0.12.24 212 | * Changing namespace name from MiniJSON to BranchThirdParty_MiniJSON 213 | 214 | - v0.3.9 215 | * Updating Branch to Android version 2.5.2 and iOS version 0.12.19 216 | * Fix for Android/iOS link-click compatibility when used with BUO. 217 | 218 | - v0.3.8 219 | * Updating Branch to Android version 2.5.1 220 | 221 | - v0.3.7 222 | * Updating Branch to Android version 2.4.7 and iOS version 0.12.16 223 | 224 | - v0.3.6 225 | * Fixing editor script for creating/updating android manifest 226 | * Fix for crash on sharesheet when user taps cancel(iOS) 227 | 228 | - v0.3.5 229 | * Fixing data retrieving when app is in background (Android) 230 | 231 | - v0.3.4 232 | * Updating Branch to Android version 2.4.5 and iOS version 0.12.11 233 | * Adding getAutoInstance() for Android platfrom (see README) 234 | * Fixing of getting deep linking data when app is in background 235 | * PostProcessBuild is enabled for iOS platfrom only 236 | 237 | - v0.3.3 238 | * Updating Branch to Android version 2.4.4 239 | 240 | - v0.3.2 241 | * Updating Branch to Android version 2.4.2 and iOS version 0.12.10 242 | * Fixing android manifest 243 | * Fixing "simulate fresh installs" for android 244 | 245 | - v0.3.1 246 | * Updating Branch to Android version 2.4.0 and iOS version 0.12.9 247 | * Returning InitSession methods for iOS 248 | 249 | - v0.3.0 250 | * Updating Branch to Android version 2.2.0 and iOS version 0.12.6 251 | * Updating Testbed 252 | * Added listOnSpotlight(string universalObject) 253 | * Deleted initSessionAsReferrable(bool isReferrable) 254 | * Deleted initSessionWithCallback(string callbackId) 255 | * Deleted initSessionAsReferrableWithCallback(bool isReferrable, string callbackId) 256 | * Deleted closeSession() 257 | * Deleted getFirstReferringParams() 258 | * Deleted getLatestReferringParams() 259 | * Deleted loadActionCountsWithCallback(string callbackId) 260 | * Deleted getTotalCountsForAction(string action) 261 | * Deleted getUniqueCountsForAction(string action) 262 | * Deleted getContentUrlWithParamsChannelAndCallback(string parametersDict, string channel, string callbackId) 263 | * Deleted getContentUrlWithParamsTagsChannelAndCallback(string parametersDict, string tags, string channel, string callbackId) 264 | * Deleted shareLink(string parameterDict, string tagList, string message, string feature, string stage, string defaultUrl, string callbackId) 265 | * Deleted getShortURLWithCallback(string callbackId) 266 | getShortURLWithParamsAndCallback(string parametersDict, string callbackId) 267 | * Deleted getShortURLWithParamsTagsChannelFeatureStageAndCallback(string parametersDict, string tags, string channel, string feature, string stage, string callbackId) 268 | * Deleted getShortURLWithParamsTagsChannelFeatureStageAliasAndCallback(string parametersDict, string tags, string channel, string feature, string stage, string alias, string callbackId) 269 | * Deleted getShortURLWithParamsTagsChannelFeatureStageTypeAndCallback(string parametersDict, string tags, string channel, string feature, string stage, int type, string callbackId) 270 | * Deleted getShortURLWithParamsTagsChannelFeatureStageMatchDurationAndCallback(string parametersDict, string tags, string channel, string feature, string stage, int matchDuration, string callbackId) 271 | * Deleted getShortURLWithParamsChannelFeatureAndCallback(string parametersDict, string channel, string feature, string callbackId) 272 | * Deleted getShortURLWithParamsChannelFeatureStageAndCallback(string parametersDict, string channel, string feature, string stage, string callbackId) 273 | * Deleted getShortURLWithParamsChannelFeatureStageAliasAndCallback(string parametersDict, string channel, string feature, string stage, string alias, string callbackId) 274 | * Deleted getShortURLWithParamsChannelFeatureStageTypeAndCallback(string parametersDict, string channel, string feature, string stage, int type, string callbackId) 275 | * Deleted getShortURLWithParamsChannelFeatureStageMatchDurationAndCallback(string parametersDict, string channel, string feature, string stage, int matchDuration, string callbackId) 276 | * Deleted getReferralUrlWithParamsTagsChannelAndCallback(string parametersDict, string tags, string channel, string callbackId) 277 | * Deleted getReferralUrlWithParamsChannelAndCallback(string parametersDict, string channel, string callbackId) 278 | * Deleted getReferralCodeWithCallback(string callbackId) 279 | * Deleted getReferralCodeWithAmountAndCallback(int amount, string callbackId) 280 | * Deleted getReferralCodeWithPrefixAmountAndCallback(string prefix, int amount, string callbackId) 281 | * Deleted getReferralCodeWithAmountExpirationAndCallback(int amount, string expiration, string callbackId) 282 | * Deleted getReferralCodeWithPrefixAmountExpirationAndCallback(string prefix, int amount, string expiration, string callbackId) 283 | * Deleted getReferralCodeWithPrefixAmountExpirationBucketTypeLocationAndCallback(string prefix, int amount, string expiration, string bucket, int calcType, int location, string callbackId) 284 | * Deleted validateReferralCodeWithCallback(string code, string callbackId) 285 | * Deleted applyReferralCodeWithCallback(string code, string callbackId) 286 | 287 | - v0.2.10 288 | * Updating Branch to Android version 1.14.3 and iOS version 0.12.3 289 | 290 | - v0.2.9 291 | * Fixing "~tags" parsing 292 | 293 | - v0.2.8 294 | * Updating Branch to Android version 1.12.1 and iOS version 0.12.2 295 | 296 | - v0.2.7 297 | * Updating Branch to Android version 1.12.0 and iOS version 0.12.1 298 | 299 | - v0.2.6 300 | * Fixing trouble with Unity5.4.x 301 | * Adding generation intent-filter for Android Path Prefixs 302 | 303 | - v0.2.5 304 | * Fixing trouble with empty expired data 305 | 306 | - v0.2.4 307 | * Fixing metadata 308 | * Fixing non-string parameters 309 | 310 | - v0.2.3 311 | * Updating Branch to Android version 1.10.8 and iOS version 0.10.17 312 | * Adding accountForFacebookSDKPreventingAppLaunch 313 | * Fixing cold launch 314 | 315 | - v0.2.2 316 | * Updating Branch to Android version 1.10.5 and iOS version 0.10.16 317 | * Fixing BranchAppController 318 | * Fixing BranchiOSWrapper 319 | 320 | - v0.2.1 321 | * Updating Branch to Android version 1.10.4 and iOS version 0.10.14 322 | * Adding auto management for Branch session 323 | * Fixing method Branch.SetDebug() 324 | * Fixing URI Scheme postprocesser (now postprocesser doesn't delete all existing settings) 325 | * Fixing parsing of BranchUniversalObject and LinkProperties 326 | 327 | - v0.2.0 328 | * Bunch of bug fixes 329 | * Cleaner integration steps 330 | * Updating Branch to Android version 1.10.1 and iOS version 0.11.8 331 | * Added setDebug 332 | * Support for Universal Links on iOS 333 | * Support for content analytics 334 | * Support for native share sheet 335 | 336 | - v0.1.4 337 | * Updating Branch to Android version 1.8.0 and iOS version 0.10.7 338 | * Updating parameter type "List<string> list" to "List<object> list" in callback BranchCallbackWithList 339 | * Updating parameter "DateTime expiration" to "DateTime? expiration" in methods getReferralCode 340 | * Adding share link functional for Android/iOS 341 | * Adding source code of demo app into BranchUnityWrapper.unitypackage 342 | * Adding full demo project archive into github 343 | * Fixing return value in method getTotalCountsForAction 344 | * Fixing return value in method getUniqueCountsForAction 345 | * Fixing methods for converting string to date in Android/iOS wrappers 346 | * Deleting method _runBlockOnThread because this method throws AndroidJavaException: java.lang.RuntimeException: Only one Looper may be created per thread 347 | 348 | - v0.1.3 Fixing a potential null pointer in the Android wrapper when no Activity was provided in the init. 349 | 350 | - v0.1.2 Fixing reverse param order on getShortUrl(params, callback) for Android. 351 | 352 | - v0.1.1 353 | * Adding missed setDebug method. 354 | * Moving to using runnables instead of Looper.prepare which conflicts with some other JNI items. 355 | * Adding compiler flags to meta. 356 | * Recompiling plugin jar with Java 1.6. 357 | -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/MiniJSON.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Calvin Rien 3 | * 4 | * Based on the JSON parser by Patrick van Bergen 5 | * http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html 6 | * 7 | * Simplified it so that it doesn't throw exceptions 8 | * and can be used in Unity iPhone with maximum code stripping. 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining 11 | * a copy of this software and associated documentation files (the 12 | * "Software"), to deal in the Software without restriction, including 13 | * without limitation the rights to use, copy, modify, merge, publish, 14 | * distribute, sublicense, and/or sell copies of the Software, and to 15 | * permit persons to whom the Software is furnished to do so, subject to 16 | * the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be 19 | * included in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 25 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 26 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 27 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | using System; 30 | using System.Collections; 31 | using System.Collections.Generic; 32 | using System.IO; 33 | using System.Text; 34 | 35 | namespace BranchThirdParty_MiniJSON { 36 | // Example usage: 37 | // 38 | // using UnityEngine; 39 | // using System.Collections; 40 | // using System.Collections.Generic; 41 | // using MiniJSON; 42 | // 43 | // public class MiniJSONTest : MonoBehaviour { 44 | // void Start () { 45 | // var jsonString = "{ \"array\": [1.44,2,3], " + 46 | // "\"object\": {\"key1\":\"value1\", \"key2\":256}, " + 47 | // "\"string\": \"The quick brown fox \\\"jumps\\\" over the lazy dog \", " + 48 | // "\"unicode\": \"\\u3041 Men\u00fa sesi\u00f3n\", " + 49 | // "\"int\": 65536, " + 50 | // "\"float\": 3.1415926, " + 51 | // "\"bool\": true, " + 52 | // "\"null\": null }"; 53 | // 54 | // var dict = Json.Deserialize(jsonString) as Dictionary<string,object>; 55 | // 56 | // Debug.Log("deserialized: " + dict.GetType()); 57 | // Debug.Log("dict['array'][0]: " + ((List<object>) dict["array"])[0]); 58 | // Debug.Log("dict['string']: " + (string) dict["string"]); 59 | // Debug.Log("dict['float']: " + (double) dict["float"]); // floats come out as doubles 60 | // Debug.Log("dict['int']: " + (long) dict["int"]); // ints come out as longs 61 | // Debug.Log("dict['unicode']: " + (string) dict["unicode"]); 62 | // 63 | // var str = Json.Serialize(dict); 64 | // 65 | // Debug.Log("serialized: " + str); 66 | // } 67 | // } 68 | 69 | /// <summary> 70 | /// This class encodes and decodes JSON strings. 71 | /// Spec. details, see http://www.json.org/ 72 | /// 73 | /// JSON uses Arrays and Objects. These correspond here to the datatypes IList and IDictionary. 74 | /// All numbers are parsed to doubles. 75 | /// </summary> 76 | public static class Json { 77 | /// <summary> 78 | /// Parses the string json into a value 79 | /// </summary> 80 | /// <param name="json">A JSON string.</param> 81 | /// <returns>An List<object>, a Dictionary<string, object>, a double, an integer,a string, null, true, or false</returns> 82 | public static object Deserialize(string json) { 83 | // save the string for debug information 84 | if (json == null) { 85 | return null; 86 | } 87 | 88 | return Parser.Parse(json); 89 | } 90 | 91 | sealed class Parser : IDisposable { 92 | const string WORD_BREAK = "{}[],:\""; 93 | 94 | public static bool IsWordBreak(char c) { 95 | return Char.IsWhiteSpace(c) || WORD_BREAK.IndexOf(c) != -1; 96 | } 97 | 98 | enum TOKEN { 99 | NONE, 100 | CURLY_OPEN, 101 | CURLY_CLOSE, 102 | SQUARED_OPEN, 103 | SQUARED_CLOSE, 104 | COLON, 105 | COMMA, 106 | STRING, 107 | NUMBER, 108 | TRUE, 109 | FALSE, 110 | NULL 111 | }; 112 | 113 | StringReader json; 114 | 115 | Parser(string jsonString) { 116 | json = new StringReader(jsonString); 117 | } 118 | 119 | public static object Parse(string jsonString) { 120 | using (var instance = new Parser(jsonString)) { 121 | return instance.ParseValue(); 122 | } 123 | } 124 | 125 | public void Dispose() { 126 | json.Dispose(); 127 | json = null; 128 | } 129 | 130 | Dictionary<string, object> ParseObject() { 131 | Dictionary<string, object> table = new Dictionary<string, object>(); 132 | 133 | // ditch opening brace 134 | json.Read(); 135 | 136 | // { 137 | while (true) { 138 | switch (NextToken) { 139 | case TOKEN.NONE: 140 | return null; 141 | case TOKEN.COMMA: 142 | continue; 143 | case TOKEN.CURLY_CLOSE: 144 | return table; 145 | default: 146 | // name 147 | string name = ParseString(); 148 | if (name == null) { 149 | return null; 150 | } 151 | 152 | // : 153 | if (NextToken != TOKEN.COLON) { 154 | return null; 155 | } 156 | // ditch the colon 157 | json.Read(); 158 | 159 | // value 160 | table[name] = ParseValue(); 161 | break; 162 | } 163 | } 164 | } 165 | 166 | List<object> ParseArray() { 167 | List<object> array = new List<object>(); 168 | 169 | // ditch opening bracket 170 | json.Read(); 171 | 172 | // [ 173 | var parsing = true; 174 | while (parsing) { 175 | TOKEN nextToken = NextToken; 176 | 177 | switch (nextToken) { 178 | case TOKEN.NONE: 179 | return null; 180 | case TOKEN.COMMA: 181 | continue; 182 | case TOKEN.SQUARED_CLOSE: 183 | parsing = false; 184 | break; 185 | default: 186 | object value = ParseByToken(nextToken); 187 | 188 | array.Add(value); 189 | break; 190 | } 191 | } 192 | 193 | return array; 194 | } 195 | 196 | object ParseValue() { 197 | TOKEN nextToken = NextToken; 198 | return ParseByToken(nextToken); 199 | } 200 | 201 | object ParseByToken(TOKEN token) { 202 | switch (token) { 203 | case TOKEN.STRING: 204 | return ParseString(); 205 | case TOKEN.NUMBER: 206 | return ParseNumber(); 207 | case TOKEN.CURLY_OPEN: 208 | return ParseObject(); 209 | case TOKEN.SQUARED_OPEN: 210 | return ParseArray(); 211 | case TOKEN.TRUE: 212 | return true; 213 | case TOKEN.FALSE: 214 | return false; 215 | case TOKEN.NULL: 216 | return null; 217 | default: 218 | return null; 219 | } 220 | } 221 | 222 | string ParseString() { 223 | StringBuilder s = new StringBuilder(); 224 | char c; 225 | 226 | // ditch opening quote 227 | json.Read(); 228 | 229 | bool parsing = true; 230 | while (parsing) { 231 | 232 | if (json.Peek() == -1) { 233 | parsing = false; 234 | break; 235 | } 236 | 237 | c = NextChar; 238 | switch (c) { 239 | case '"': 240 | parsing = false; 241 | break; 242 | case '\\': 243 | if (json.Peek() == -1) { 244 | parsing = false; 245 | break; 246 | } 247 | 248 | c = NextChar; 249 | switch (c) { 250 | case '"': 251 | case '\\': 252 | case '/': 253 | s.Append(c); 254 | break; 255 | case 'b': 256 | s.Append('\b'); 257 | break; 258 | case 'f': 259 | s.Append('\f'); 260 | break; 261 | case 'n': 262 | s.Append('\n'); 263 | break; 264 | case 'r': 265 | s.Append('\r'); 266 | break; 267 | case 't': 268 | s.Append('\t'); 269 | break; 270 | case 'u': 271 | var hex = new char[4]; 272 | 273 | for (int i=0; i< 4; i++) { 274 | hex[i] = NextChar; 275 | } 276 | 277 | s.Append((char) Convert.ToInt32(new string(hex), 16)); 278 | break; 279 | } 280 | break; 281 | default: 282 | s.Append(c); 283 | break; 284 | } 285 | } 286 | 287 | return s.ToString(); 288 | } 289 | 290 | object ParseNumber() { 291 | string number = NextWord; 292 | 293 | if (number.IndexOf('.') == -1) { 294 | long parsedInt; 295 | Int64.TryParse(number, out parsedInt); 296 | return parsedInt; 297 | } 298 | 299 | double parsedDouble; 300 | Double.TryParse(number, out parsedDouble); 301 | return parsedDouble; 302 | } 303 | 304 | void EatWhitespace() { 305 | while (Char.IsWhiteSpace(PeekChar)) { 306 | json.Read(); 307 | 308 | if (json.Peek() == -1) { 309 | break; 310 | } 311 | } 312 | } 313 | 314 | char PeekChar { 315 | get { 316 | return Convert.ToChar(json.Peek()); 317 | } 318 | } 319 | 320 | char NextChar { 321 | get { 322 | return Convert.ToChar(json.Read()); 323 | } 324 | } 325 | 326 | string NextWord { 327 | get { 328 | StringBuilder word = new StringBuilder(); 329 | 330 | while (!IsWordBreak(PeekChar)) { 331 | word.Append(NextChar); 332 | 333 | if (json.Peek() == -1) { 334 | break; 335 | } 336 | } 337 | 338 | return word.ToString(); 339 | } 340 | } 341 | 342 | TOKEN NextToken { 343 | get { 344 | EatWhitespace(); 345 | 346 | if (json.Peek() == -1) { 347 | return TOKEN.NONE; 348 | } 349 | 350 | switch (PeekChar) { 351 | case '{': 352 | return TOKEN.CURLY_OPEN; 353 | case '}': 354 | json.Read(); 355 | return TOKEN.CURLY_CLOSE; 356 | case '[': 357 | return TOKEN.SQUARED_OPEN; 358 | case ']': 359 | json.Read(); 360 | return TOKEN.SQUARED_CLOSE; 361 | case ',': 362 | json.Read(); 363 | return TOKEN.COMMA; 364 | case '"': 365 | return TOKEN.STRING; 366 | case ':': 367 | return TOKEN.COLON; 368 | case '0': 369 | case '1': 370 | case '2': 371 | case '3': 372 | case '4': 373 | case '5': 374 | case '6': 375 | case '7': 376 | case '8': 377 | case '9': 378 | case '-': 379 | return TOKEN.NUMBER; 380 | } 381 | 382 | switch (NextWord) { 383 | case "false": 384 | return TOKEN.FALSE; 385 | case "true": 386 | return TOKEN.TRUE; 387 | case "null": 388 | return TOKEN.NULL; 389 | } 390 | 391 | return TOKEN.NONE; 392 | } 393 | } 394 | } 395 | 396 | /// <summary> 397 | /// Converts a IDictionary / IList object or a simple type (string, int, etc.) into a JSON string 398 | /// </summary> 399 | /// <param name="json">A Dictionary<string, object> / List<object></param> 400 | /// <returns>A JSON encoded string, or null if object 'json' is not serializable</returns> 401 | public static string Serialize(object obj) { 402 | return Serializer.Serialize(obj); 403 | } 404 | 405 | sealed class Serializer { 406 | StringBuilder builder; 407 | 408 | Serializer() { 409 | builder = new StringBuilder(); 410 | } 411 | 412 | public static string Serialize(object obj) { 413 | var instance = new Serializer(); 414 | 415 | instance.SerializeValue(obj); 416 | 417 | return instance.builder.ToString(); 418 | } 419 | 420 | void SerializeValue(object value) { 421 | IList asList; 422 | IDictionary asDict; 423 | string asStr; 424 | 425 | if (value == null) { 426 | builder.Append("null"); 427 | } else if ((asStr = value as string) != null) { 428 | SerializeString(asStr); 429 | } else if (value is bool) { 430 | builder.Append((bool) value ? "true" : "false"); 431 | } else if ((asList = value as IList) != null) { 432 | SerializeArray(asList); 433 | } else if ((asDict = value as IDictionary) != null) { 434 | SerializeObject(asDict); 435 | } else if (value is char) { 436 | SerializeString(new string((char) value, 1)); 437 | } else { 438 | SerializeOther(value); 439 | } 440 | } 441 | 442 | void SerializeObject(IDictionary obj) { 443 | bool first = true; 444 | 445 | builder.Append('{'); 446 | 447 | foreach (object e in obj.Keys) { 448 | if (!first) { 449 | builder.Append(','); 450 | } 451 | 452 | SerializeString(e.ToString()); 453 | builder.Append(':'); 454 | 455 | SerializeValue(obj[e]); 456 | 457 | first = false; 458 | } 459 | 460 | builder.Append('}'); 461 | } 462 | 463 | void SerializeArray(IList anArray) { 464 | builder.Append('['); 465 | 466 | bool first = true; 467 | 468 | foreach (object obj in anArray) { 469 | if (!first) { 470 | builder.Append(','); 471 | } 472 | 473 | SerializeValue(obj); 474 | 475 | first = false; 476 | } 477 | 478 | builder.Append(']'); 479 | } 480 | 481 | void SerializeString(string str) { 482 | builder.Append('\"'); 483 | 484 | char[] charArray = str.ToCharArray(); 485 | foreach (var c in charArray) { 486 | switch (c) { 487 | case '"': 488 | builder.Append("\\\""); 489 | break; 490 | case '\\': 491 | builder.Append("\\\\"); 492 | break; 493 | case '\b': 494 | builder.Append("\\b"); 495 | break; 496 | case '\f': 497 | builder.Append("\\f"); 498 | break; 499 | case '\n': 500 | builder.Append("\\n"); 501 | break; 502 | case '\r': 503 | builder.Append("\\r"); 504 | break; 505 | case '\t': 506 | builder.Append("\\t"); 507 | break; 508 | default: 509 | int codepoint = Convert.ToInt32(c); 510 | if ((codepoint >= 32) && (codepoint <= 126)) { 511 | builder.Append(c); 512 | } else { 513 | builder.Append("\\u"); 514 | builder.Append(codepoint.ToString("x4")); 515 | } 516 | break; 517 | } 518 | } 519 | 520 | builder.Append('\"'); 521 | } 522 | 523 | void SerializeOther(object value) { 524 | // NOTE: decimals lose precision during serialization. 525 | // They always have, I'm just letting you know. 526 | // Previously floats and doubles lost precision too. 527 | if (value is float) { 528 | builder.Append(((float) value).ToString("R")); 529 | } else if (value is int 530 | || value is uint 531 | || value is long 532 | || value is sbyte 533 | || value is byte 534 | || value is short 535 | || value is ushort 536 | || value is ulong) { 537 | builder.Append(value); 538 | } else if (value is double 539 | || value is decimal) { 540 | builder.Append(Convert.ToDouble(value).ToString("R")); 541 | } else { 542 | SerializeString(value.ToString()); 543 | } 544 | } 545 | } 546 | } 547 | } -------------------------------------------------------------------------------- /BranchUnityTestBed/Assets/Branch/Editor/BranchEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections; 4 | using System.Text.RegularExpressions; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Xml; 9 | using System.IO; 10 | 11 | [CustomEditor(typeof(Branch))] 12 | public class BranchEditor : Editor { 13 | 14 | SerializedObject serializedBranchData; 15 | SerializedProperty serializedTestAppLinks; 16 | SerializedProperty serializedAppLinks; 17 | 18 | const string assetPath = "Assets/Branch/Resources/BranchData.asset"; 19 | const string copyPath = "Assets/Branch/Resources/BranchDataBackupCopy.asset"; 20 | 21 | 22 | private void OnEnable() 23 | { 24 | // Prevent overwriting settings on SDK upgrade. 25 | // Check for an existing working copy and if it doesn't exist create a new working copy 26 | // In the future, consider versioning and migrating the data. 27 | if (CopyExists()) { 28 | RestoreBranchDataFromCopy(); 29 | } 30 | 31 | // Loads existing settings 32 | serializedBranchData = new SerializedObject(BranchData.Instance); 33 | serializedTestAppLinks = serializedBranchData.FindProperty("testAppLinks"); 34 | serializedAppLinks = serializedBranchData.FindProperty("liveAppLinks"); 35 | } 36 | 37 | private bool CopyExists() 38 | { 39 | var asset = Resources.Load(copyPath); 40 | if (asset != null) { 41 | return true; 42 | } 43 | return false; 44 | } 45 | 46 | private void RestoreBranchDataFromCopy() 47 | { 48 | if (!AssetDatabase.CopyAsset(copyPath, assetPath)) { 49 | Debug.LogWarning($"Failed to restore Branch Settings from a backup Copy"); 50 | } 51 | } 52 | 53 | private void UpdateBranchDataCopy() 54 | { 55 | if (!AssetDatabase.CopyAsset(assetPath, copyPath)) { 56 | Debug.LogWarning($"Failed to save Branch Settings into a backup Copy"); 57 | } 58 | } 59 | 60 | public override void OnInspectorGUI() { 61 | GUI.changed = false; 62 | 63 | // TODO: handle enableLogging. Due to lifecycle issues it is best to set this in branch.json. Which not yet supportted. 64 | SerializedProperty serializedEnableLogging = serializedBranchData.FindProperty("enableLogging"); 65 | SerializedProperty serializedIsTestMode = serializedBranchData.FindProperty("testMode"); 66 | 67 | SerializedProperty serializedTestBranchKey = serializedBranchData.FindProperty("testBranchKey"); 68 | SerializedProperty serializedTestBranchUri = serializedBranchData.FindProperty("testBranchUri"); 69 | SerializedProperty serializedTestAndroidPathPrefix = serializedBranchData.FindProperty("testAndroidPathPrefix"); 70 | 71 | SerializedProperty serializedBranchKey = serializedBranchData.FindProperty("liveBranchKey"); 72 | SerializedProperty serializedBranchUri = serializedBranchData.FindProperty("liveBranchUri"); 73 | SerializedProperty serializedAndroidPathPrefix = serializedBranchData.FindProperty("liveAndroidPathPrefix"); 74 | 75 | EditorGUILayout.PropertyField(serializedEnableLogging, new GUILayoutOption[]{}); 76 | EditorGUILayout.PropertyField(serializedIsTestMode, new GUILayoutOption[]{}); 77 | 78 | EditorGUILayout.Separator(); 79 | EditorGUILayout.PropertyField(serializedBranchKey, new GUILayoutOption[]{}); 80 | EditorGUILayout.PropertyField(serializedBranchUri, new GUILayoutOption[]{}); 81 | EditorGUILayout.PropertyField(serializedAndroidPathPrefix, new GUILayoutOption[]{}); 82 | EditorGUILayout.PropertyField(serializedAppLinks, true, new GUILayoutOption[]{}); 83 | 84 | EditorGUILayout.Separator(); 85 | EditorGUILayout.PropertyField(serializedTestBranchKey, new GUILayoutOption[]{}); 86 | EditorGUILayout.PropertyField(serializedTestBranchUri, new GUILayoutOption[]{}); 87 | EditorGUILayout.PropertyField(serializedTestAndroidPathPrefix, new GUILayoutOption[]{}); 88 | EditorGUILayout.PropertyField(serializedTestAppLinks, true, new GUILayoutOption[]{}); 89 | 90 | EditorGUILayout.Separator(); 91 | 92 | // iOS config update is done post build, in BranchPostProcessBuild.cs. 93 | // Android config update is done pre build here. 94 | EditorGUILayout.BeginHorizontal(new GUILayoutOption[]{}); 95 | if (GUILayout.Button("Apply Changes", new GUILayoutOption[]{})) { 96 | UpdateBranchDataCopy(); 97 | UpdateManifest(); 98 | AssetDatabase.Refresh(); 99 | } 100 | EditorGUILayout.EndHorizontal(); 101 | EditorGUILayout.Separator(); 102 | 103 | EditorGUILayout.BeginHorizontal(new GUILayoutOption[]{}); 104 | EditorGUILayout.HelpBox("Test mode option is not working on iOS when set here. Set `useTestInstance` true in `Assets/StreamingAssets/branch.json`.", MessageType.Info); 105 | EditorGUILayout.EndHorizontal(); 106 | 107 | EditorGUILayout.BeginHorizontal(new GUILayoutOption[]{}); 108 | EditorGUILayout.HelpBox("Enable logging option is not working when set here. Set `enableLogging` true in `Assets/StreamingAssets/branch.json`.", MessageType.Info); 109 | EditorGUILayout.EndHorizontal(); 110 | 111 | EditorGUILayout.BeginHorizontal(new GUILayoutOption[]{}); 112 | EditorGUILayout.HelpBox("Native code runs prior to C# runtime startup, this can lead to the install event missing any options set in C# code. To force the native code to wait, set `deferInitForPluginRuntime` true in `Assets/StreamingAssets/branch.json`.", MessageType.Info); 113 | EditorGUILayout.EndHorizontal(); 114 | 115 | // Saves on UI change 116 | if (GUI.changed) { 117 | serializedBranchData.ApplyModifiedProperties(); 118 | EditorUtility.SetDirty(BranchData.Instance); 119 | AssetDatabase.SaveAssets(); 120 | AssetDatabase.Refresh(); 121 | } 122 | } 123 | 124 | #region Manifest update 125 | 126 | public static void UpdateManifest() { 127 | 128 | string manifestFolder = Path.Combine(Application.dataPath, "Plugins/Android"); 129 | 130 | // Are both these necessary? 131 | string defaultManifestPath = Path.Combine(Application.dataPath, "Plugins/Branch/Android/AndroidManifest.xml"); 132 | string manifestPath = Path.Combine(Application.dataPath, "Plugins/Android/AndroidManifest.xml"); 133 | 134 | if (!File.Exists(manifestPath)) { 135 | 136 | if (!Directory.Exists(manifestFolder)) { 137 | Directory.CreateDirectory(manifestFolder); 138 | } 139 | 140 | File.Copy(defaultManifestPath, manifestPath); 141 | } 142 | 143 | // Opening android manifest 144 | XmlDocument xmlDoc = new XmlDocument(); 145 | xmlDoc.Load(manifestPath); 146 | 147 | XmlElement rootElem = xmlDoc.DocumentElement; 148 | XmlNode appNode = null; 149 | XmlNode unityActivityNode = null; 150 | 151 | // change package name, pretty sure this should be done in Unity build settings 152 | // rootElem.SetAttribute("package", Application.identifier); 153 | 154 | // finding node named "application" 155 | foreach(XmlNode node in rootElem.ChildNodes) { 156 | if (node.Name == "application") { 157 | appNode = node; 158 | 159 | XmlElement appElem = appNode as XmlElement; 160 | if (!appElem.HasAttribute("android:name")) { 161 | appElem.SetAttribute("android____name", "io.branch.unity.BranchUnityApp"); 162 | } 163 | break; 164 | } 165 | } 166 | 167 | if (appNode == null) { 168 | Debug.LogError("Current Android Manifest was broken, it does not contain \"<application>\" node"); 169 | return; 170 | } 171 | 172 | // finding UnityPlayerActivity node 173 | foreach(XmlNode node in appNode.ChildNodes) { 174 | if (unityActivityNode != null) { 175 | break; 176 | } 177 | 178 | if (node.Name == "activity") { 179 | foreach(XmlAttribute attr in node.Attributes) { 180 | if (attr.Name.Contains("launchMode") && attr.Value == "singleTask") { 181 | unityActivityNode = node; 182 | break; 183 | } 184 | } 185 | } 186 | } 187 | 188 | if (unityActivityNode == null) { 189 | Debug.LogError("Current Android Manifest was broken, it does not contain an activity with launchMode=\"singleTask\""); 190 | return; 191 | } 192 | 193 | // Adding intent-filter for Branch URI into UnityPlayerActivity activity 194 | UpdateURIFilter(xmlDoc, unityActivityNode); 195 | 196 | // Adding intent-filter for link domains into UnityPlayerActivity activity 197 | UpdateLinkDomainsFilter(xmlDoc, unityActivityNode); 198 | 199 | // Adding permissions 200 | UpdatePermissions(xmlDoc); 201 | 202 | // Adding debug mode meta and branch key 203 | UpdateDebugModeMeta(xmlDoc, appNode); 204 | 205 | // Saving android manifest 206 | xmlDoc.Save(manifestPath); 207 | 208 | //Changing "android___" to "android:" after changings 209 | TextReader manifestReader = new StreamReader(manifestPath); 210 | string content = manifestReader.ReadToEnd(); 211 | manifestReader.Close(); 212 | 213 | Regex regex = new Regex("android____"); 214 | content = regex.Replace (content, "android:"); 215 | 216 | TextWriter manifestWriter = new StreamWriter(manifestPath); 217 | manifestWriter.Write(content); 218 | manifestWriter.Close(); 219 | } 220 | 221 | public static void UpdateURIFilter(XmlDocument doc, XmlNode unityActivityNode) { 222 | XmlNode intentFilterNode = null; 223 | 224 | // update or adding intent-filter 225 | foreach(XmlNode node in unityActivityNode.ChildNodes) { 226 | if (intentFilterNode != null) { 227 | break; 228 | } 229 | 230 | if (node.Name == "intent-filter") { 231 | foreach(XmlNode childNode in node.ChildNodes) { 232 | foreach(XmlAttribute attr in childNode.Attributes) { 233 | if (attr.Name.Contains("host") && attr.Value == "open") { 234 | intentFilterNode = node; 235 | break; 236 | } 237 | } 238 | } 239 | } 240 | } 241 | 242 | // delete old intent-filter 243 | if (intentFilterNode != null) { 244 | unityActivityNode.RemoveChild(intentFilterNode); 245 | } 246 | 247 | // is URI present? 248 | if (BranchData.Instance.testMode && string.IsNullOrEmpty(BranchData.Instance.testBranchUri)) { 249 | return; 250 | } else if (!BranchData.Instance.testMode && string.IsNullOrEmpty(BranchData.Instance.liveBranchUri)) { 251 | return; 252 | } 253 | 254 | // <intent-filter> 255 | // <data android:scheme="APP_URI" android:host="open" /> 256 | // <action android:name="android.intent.action.VIEW" /> 257 | // <category android:name="android.intent.category.DEFAULT" /> 258 | // <category android:name="android.intent.category.BROWSABLE" /> 259 | // </intent-filter> 260 | 261 | // adding new intent-filter 262 | XmlElement ifElem = doc.CreateElement("intent-filter"); 263 | 264 | XmlElement ifData = doc.CreateElement("data"); 265 | ifData.SetAttribute("android____host", "open"); 266 | 267 | if (BranchData.Instance.testMode) { 268 | ifData.SetAttribute("android____scheme", BranchData.Instance.testBranchUri); 269 | } else { 270 | ifData.SetAttribute("android____scheme", BranchData.Instance.liveBranchUri); 271 | } 272 | 273 | XmlElement ifAction = doc.CreateElement("action"); 274 | ifAction.SetAttribute("android____name", "android.intent.action.VIEW"); 275 | 276 | XmlElement ifCategory01 = doc.CreateElement("category"); 277 | ifCategory01.SetAttribute("android____name", "android.intent.category.DEFAULT"); 278 | 279 | XmlElement ifCategory02 = doc.CreateElement("category"); 280 | ifCategory02.SetAttribute("android____name", "android.intent.category.BROWSABLE"); 281 | 282 | ifElem.AppendChild(ifData); 283 | ifElem.AppendChild(ifAction); 284 | ifElem.AppendChild(ifCategory01); 285 | ifElem.AppendChild(ifCategory02); 286 | unityActivityNode.AppendChild(ifElem); 287 | } 288 | 289 | public static void UpdateLinkDomainsFilter(XmlDocument doc, XmlNode unityActivityNode) { 290 | XmlNode intentFilterNode = null; 291 | 292 | // update or adding intent-filter 293 | foreach(XmlNode node in unityActivityNode.ChildNodes) { 294 | if (intentFilterNode != null) { 295 | break; 296 | } 297 | 298 | if (node.Name == "intent-filter") { 299 | foreach(XmlNode childNode in node.ChildNodes) { 300 | foreach(XmlAttribute attr in childNode.Attributes) { 301 | if (attr.Name.Contains("scheme") && attr.Value == "https") { 302 | intentFilterNode = node; 303 | } 304 | } 305 | } 306 | } 307 | } 308 | 309 | if (intentFilterNode != null) { 310 | unityActivityNode.RemoveChild(intentFilterNode); 311 | } 312 | 313 | // <intent-filter android:autoVerify="true"> 314 | // <action android:name="android.intent.action.VIEW" /> 315 | // <category android:name="android.intent.category.DEFAULT" /> 316 | // <category android:name="android.intent.category.BROWSABLE" /> 317 | // <data android:scheme="https" android:host="xxxx.app.link" /> 318 | // <data android:scheme="https" android:host="bnc.lt" android:pathPrefix="/pref" /> 319 | // <data android:scheme="https" android:host="custom.dom" android:pathPrefix="/pref" /> 320 | // </intent-filter> 321 | 322 | // adding intent-filter 323 | XmlElement ifElem = doc.CreateElement("intent-filter"); 324 | ifElem.SetAttribute("android____autoVerify", "true"); 325 | 326 | XmlElement ifAction = doc.CreateElement("action"); 327 | ifAction.SetAttribute("android____name", "android.intent.action.VIEW"); 328 | 329 | XmlElement ifCategory01 = doc.CreateElement("category"); 330 | ifCategory01.SetAttribute("android____name", "android.intent.category.DEFAULT"); 331 | 332 | XmlElement ifCategory02 = doc.CreateElement("category"); 333 | ifCategory02.SetAttribute("android____name", "android.intent.category.BROWSABLE"); 334 | 335 | ifElem.AppendChild(ifAction); 336 | ifElem.AppendChild(ifCategory01); 337 | ifElem.AppendChild(ifCategory02); 338 | 339 | if (BranchData.Instance.testMode) { 340 | if (BranchData.Instance.testAppLinks.Length > 0) { 341 | foreach(string link in BranchData.Instance.testAppLinks) { 342 | XmlElement ifData = doc.CreateElement("data"); 343 | 344 | if (link.Contains("bnc.lt") || link.Contains("app.link")) { 345 | ifData.SetAttribute("android____scheme", "https"); 346 | } else { 347 | ifData.SetAttribute("android____scheme", "https"); 348 | } 349 | 350 | ifData.SetAttribute("android____host", link); 351 | ifElem.AppendChild(ifData); 352 | } 353 | } else if (!string.IsNullOrEmpty(BranchData.Instance.testAndroidPathPrefix)) { 354 | XmlElement ifData = doc.CreateElement("data"); 355 | ifData.SetAttribute("android____scheme", "https"); 356 | ifData.SetAttribute("android____host", "bnc.lt"); 357 | ifData.SetAttribute("android____pathPrefix", BranchData.Instance.testAndroidPathPrefix); 358 | ifElem.AppendChild(ifData); 359 | } else { 360 | return; 361 | } 362 | } else { 363 | if (BranchData.Instance.liveAppLinks.Length > 0) { 364 | foreach(string link in BranchData.Instance.liveAppLinks) { 365 | XmlElement ifData = doc.CreateElement("data"); 366 | 367 | if (link.Contains("bnc.lt") || link.Contains("app.link")) { 368 | ifData.SetAttribute("android____scheme", "https"); 369 | } else { 370 | ifData.SetAttribute("android____scheme", "https"); 371 | } 372 | 373 | ifData.SetAttribute("android____host", link); 374 | ifElem.AppendChild(ifData); 375 | } 376 | } else if (!string.IsNullOrEmpty(BranchData.Instance.testAndroidPathPrefix)) { 377 | XmlElement ifData = doc.CreateElement("data"); 378 | ifData.SetAttribute("android____scheme", "https"); 379 | ifData.SetAttribute("android____host", "bnc.lt"); 380 | ifData.SetAttribute("android____pathPrefix", BranchData.Instance.liveAndroidPathPrefix); 381 | ifElem.AppendChild(ifData); 382 | } else { 383 | return; 384 | } 385 | } 386 | 387 | unityActivityNode.AppendChild(ifElem); 388 | } 389 | 390 | public static void UpdatePermissions(XmlDocument doc) { 391 | // we have to add the next permissions: 392 | // <uses-permission android:name="android.permission.INTERNET" /> 393 | 394 | bool isInternetPermission = false; 395 | 396 | // finding permissions nodes 397 | XmlElement rootElem = doc.DocumentElement; 398 | 399 | foreach(XmlNode node in rootElem.ChildNodes) { 400 | if (node.Name == "uses-permission") { 401 | foreach(XmlAttribute attr in node.Attributes) { 402 | if (attr.Value.Contains("android.permission.INTERNET")) { 403 | isInternetPermission = true; 404 | } 405 | } 406 | } 407 | } 408 | 409 | // adding permissions if need 410 | // we add "android____name" because there is some troubles to add android:name 411 | if (!isInternetPermission) { 412 | XmlElement elem = doc.CreateElement("uses-permission"); 413 | elem.SetAttribute("android____name", "android.permission.INTERNET"); 414 | rootElem.AppendChild(elem); 415 | } 416 | } 417 | 418 | 419 | public static void UpdateDebugModeMeta(XmlDocument doc, XmlNode appNode) { 420 | // <meta-data android:name="io.branch.sdk.TestMode" android:value="true" /> 421 | // <meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_.." /> 422 | // <meta-data android:name="io.branch.sdk.BranchKey.test" android:value="key_test_.." /> 423 | 424 | XmlNode metaDataNode = null; 425 | XmlNode metaDataKeyNode = null; 426 | 427 | // update or adding intent-filter 428 | foreach(XmlNode node in appNode.ChildNodes) { 429 | if (node.Name == "meta-data") { 430 | foreach(XmlAttribute attr in node.Attributes) { 431 | if (metaDataNode == null && attr.Value.Contains("io.branch.sdk.TestMode")) { 432 | metaDataNode = node; 433 | } 434 | 435 | if (metaDataKeyNode == null && attr.Value.Contains("io.branch.sdk.BranchKey")) { 436 | metaDataKeyNode = node; 437 | } 438 | } 439 | } 440 | } 441 | 442 | // TODO: enable logging control on Android via manifest 443 | /* 444 | XmlElement debugMetaData = doc.CreateElement("meta-data"); 445 | debugMetaData.SetAttribute("android____name", "io.branch.sdk.TestMode"); 446 | debugMetaData.SetAttribute("android____value", BranchData.Instance.enableLogging ? "true" : "false"); 447 | if (metaDataNode == null) { 448 | appNode.AppendChild(debugMetaData); 449 | } else { 450 | appNode.ReplaceChild(debugMetaData, metaDataNode); 451 | } 452 | */ 453 | 454 | XmlElement keyMetaData = doc.CreateElement("meta-data"); 455 | 456 | if (BranchData.Instance.testMode) { 457 | keyMetaData.SetAttribute("android____name", "io.branch.sdk.BranchKey.test"); 458 | keyMetaData.SetAttribute("android____value", BranchData.Instance.testBranchKey); 459 | } else { 460 | keyMetaData.SetAttribute("android____name", "io.branch.sdk.BranchKey"); 461 | keyMetaData.SetAttribute("android____value", BranchData.Instance.liveBranchKey); 462 | } 463 | 464 | if (metaDataKeyNode == null) { 465 | appNode.AppendChild(keyMetaData); 466 | } else { 467 | appNode.ReplaceChild(keyMetaData, metaDataKeyNode); 468 | } 469 | } 470 | 471 | #endregion 472 | } 473 | --------------------------------------------------------------------------------