From 3847d1caf465678af8747bd13b052599d313d75c Mon Sep 17 00:00:00 2001 From: Chouaib Mounaime Date: Thu, 30 Nov 2023 14:09:46 +0100 Subject: [PATCH] fix ios setAttribute method (#23) * fix ios setAttribute method --- Editor/ExternalDependencies.xml | 2 +- Editor/PurchaselyPostProcessor.cs | 11 +++-- Native/IOS/PurchaselyBridge.mm | 2 +- Runtime/Enums.cs | 42 +++++++++---------- .../Scripts/PurchaselyDemoController.cs | 3 ++ package.json | 2 +- 6 files changed, 34 insertions(+), 28 deletions(-) diff --git a/Editor/ExternalDependencies.xml b/Editor/ExternalDependencies.xml index 1fa3bb3..7c83983 100644 --- a/Editor/ExternalDependencies.xml +++ b/Editor/ExternalDependencies.xml @@ -13,6 +13,6 @@ - + diff --git a/Editor/PurchaselyPostProcessor.cs b/Editor/PurchaselyPostProcessor.cs index da7f13f..3fbdac3 100644 --- a/Editor/PurchaselyPostProcessor.cs +++ b/Editor/PurchaselyPostProcessor.cs @@ -24,7 +24,7 @@ public static void OnPostProcessBuild(BuildTarget buildTarget, string buildPath) DisableBitcode(buildPath); // Debug.Log("Installing for iOS. Adding Purchasely SDK"); - // AddPurchaselyFramework(buildPath); + AddPurchaselyFramework(buildPath); #endif } } @@ -42,11 +42,14 @@ private static void AddPurchaselyFramework(string path) string frameworkName = frameworkRawName + ".xcframework"; var src = Path.Combine("Pods", frameworkRawName, "Purchasely/Frameworks", frameworkName); var frameworkPath = project.AddFile(src, src); - + project.AddFileToBuild(mainTargetGUID, frameworkPath); - // Appears to be useless - // project.AddFileToEmbedFrameworks(mainTargetGUID, frameworkPath); + // Check if the framework is already present before adding to embed frameworks + if (!project.ContainsFileByProjectPath(frameworkPath)) + { + project.AddFileToEmbedFrameworks(mainTargetGUID, frameworkPath); + } project.WriteToFile(projPath); } diff --git a/Native/IOS/PurchaselyBridge.mm b/Native/IOS/PurchaselyBridge.mm index a75d700..1eaaade 100644 --- a/Native/IOS/PurchaselyBridge.mm +++ b/Native/IOS/PurchaselyBridge.mm @@ -468,7 +468,7 @@ void _purchaselyUserLogout() { } void _purchaselySetAttribute(int attribute, const char* value) { - [Purchasely setAttribute:attribute value:value]; + [Purchasely setAttribute:(PLYAttribute)attribute value:[PLYUtils createNSStringFrom:value]]; } void _purchaselySetStringAttribute(const char* key, const char* value) { diff --git a/Runtime/Enums.cs b/Runtime/Enums.cs index 97ccce3..e427b48 100644 --- a/Runtime/Enums.cs +++ b/Runtime/Enums.cs @@ -45,26 +45,26 @@ public enum PresentationType public enum PLYAttribute { - FIREBASE_APP_INSTANCE_ID = 0, - AIRSHIP_CHANNEL_ID = 1, - AIRSHIP_USER_ID = 2, - BATCH_INSTALLATION_ID = 3, - ADJUST_ID = 4, - APPSFLYER_ID = 5, - ONESIGNAL_PLAYER_ID = 6, - MIXPANEL_DISTINCT_ID = 7, - CLEVER_TAP_ID = 8, - SENDINBLUE_USER_EMAIL = 9, - ITERABLE_USER_EMAIL = 10, - ITERABLE_USER_ID = 11, - AT_INTERNET_ID_CLIENT = 12, - MPARTICLE_USER_ID = 13, - CUSTOMERIO_USER_ID = 14, - CUSTOMERIO_USER_EMAIL = 15, - BRANCH_USER_DEVELOPER_IDENTITY = 16, - AMPLITUDE_USER_ID = 17, - AMPLITUDE_DEVICE_ID = 18, - MOENGAGE_UNIQUE_ID = 19, - ONESIGNAL_EXTERNAL_ID = 20, + AMPLITUDE_USER_ID = 0, + AMPLITUDE_DEVICE_ID = 1, + FIREBASE_APP_INSTANCE_ID = 2, + AIRSHIP_CHANNEL_ID = 3, + AIRSHIP_USER_ID = 4, + BATCH_INSTALLATION_ID = 5, + ADJUST_ID = 6, + APPSFLYER_ID = 7, + ONESIGNAL_PLAYER_ID = 8, + MIXPANEL_DISTINCT_ID = 9, + CLEVER_TAP_ID = 10, + SENDINBLUE_USER_EMAIL = 11, + ITERABLE_USER_ID = 12, + ITERABLE_USER_EMAIL = 13, + AT_INTERNET_ID_CLIENT = 14, + MPARTICLE_USER_ID = 15, + BRANCH_USER_DEVELOPER_IDENTITY = 16, + CUSTOMERIO_USER_EMAIL = 17, + CUSTOMERIO_USER_ID = 18, + MOENGAGE_UNIQUE_ID = 19, + } } \ No newline at end of file diff --git a/Samples~/purchasely-demo/Scripts/PurchaselyDemoController.cs b/Samples~/purchasely-demo/Scripts/PurchaselyDemoController.cs index e9658ef..630d282 100644 --- a/Samples~/purchasely-demo/Scripts/PurchaselyDemoController.cs +++ b/Samples~/purchasely-demo/Scripts/PurchaselyDemoController.cs @@ -254,6 +254,9 @@ private void OnPurchaselyStart(bool success, string error) _purchasely.IsDeeplinkHandled("https://purchasely.com"); Log($"Purchasely isAnonymous. {_purchasely.IsAnonymous()}"); + + _purchasely.SetAttribute(PLYAttribute.ADJUST_ID, "test_adjust_id"); + _purchasely.SetAttribute(PLYAttribute.APPSFLYER_ID, "test_appsflyer_id"); } private void OnPurchaselyEvent(Event @event) diff --git a/package.json b/package.json index 34b8a7e..afe49fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.purchasely.unity", - "version": "4.1.3", + "version": "4.1.4", "displayName": "Purchasely", "description": "Subscription optimization made easy", "unity": "2019.4",