diff --git a/CHANGELOG.md b/CHANGELOG.md index 27065c66..ce9676d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 6.6.0 +* Updated Native `Android` and `iOS` SDKs: + * Android Native SDK Update 5.4.+ - [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases) + * iOS Native SDK Update 2.1.0 - [iOS Version History](https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/releases) + +* New Methods: + - `addSnapPartnerParameter` - See [documentation](https://help.branch.io/using-branch/docs/snap) on partner parameters for details. + ## 6.5.0 * Updated Native `iOS` SDK: * iOS Native SDK Update 2.0.0 - [iOS Version History](https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/releases) diff --git a/README.md b/README.md index c70fffa8..adf47211 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Branch.io helps mobile apps grow with deep links that power referral systems, sh Supports Android, iOS and Web. -* Android - Branch SDK Version >= 5.2.+ [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases) -* iOS - Branch SDK Version >= 2.0.+ [iOS Version History](https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/releases) +* Android - Branch SDK Version >= 5.4.+ [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases) +* iOS - Branch SDK Version >= 2.1.+ [iOS Version History](https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/releases) Implemented functions in plugin: @@ -429,8 +429,8 @@ The `BranchEvent` interface provides an interface to add contents represented by Analytics about your app's BranchEvents can be found on the Branch dashboard, and BranchEvents also provide tight integration with many third party analytics providers. ```dart -BranchEvent eventStandart = BranchEvent.standardEvent(BranchStandardEvent.ADD_TO_CART); -FlutterBranchSdk.trackContent(buo: [buo], branchEvent: eventStandart); +BranchEvent eventStandard = BranchEvent.standardEvent(BranchStandardEvent.ADD_TO_CART); +FlutterBranchSdk.trackContent(buo: [buo], branchEvent: eventStandard); ``` You can use your own custom event names too: @@ -441,21 +441,19 @@ FlutterBranchSdk.trackContent(buo: [buo], branchEvent: eventCustom); Extra event specific data can be tracked with the event as well: ```dart - eventStandart.transactionID = '12344555'; - eventStandart.currency = BranchCurrencyType.BRL; - eventStandart.revenue = 1.5; - eventStandart.shipping = 10.2; - eventStandart.tax = 12.3; - eventStandart.coupon = 'test_coupon'; - eventStandart.affiliation = 'test_affiliation'; - eventStandart.eventDescription = 'Event_description'; - eventStandart.searchQuery = 'item 123'; - eventStandart.adType = BranchEventAdType.BANNER; - eventStandart.addCustomData( - 'Custom_Event_Property_Key1', 'Custom_Event_Property_val1'); - eventStandart.addCustomData( - 'Custom_Event_Property_Key2', 'Custom_Event_Property_val2'); - FlutterBranchSdk.trackContent(buo: [buo], branchEvent: eventStandart); + eventStandard.transactionID = '12344555'; + eventStandard.currency = BranchCurrencyType.BRL; + eventStandard.revenue = 1.5; + eventStandard.shipping = 10.2; + eventStandard.tax = 12.3; + eventStandard.coupon = 'test_coupon'; + eventStandard.affiliation = 'test_affiliation'; + eventStandard.eventDescription = 'Event_description'; + eventStandard.searchQuery = 'item 123'; + eventStandard.adType = BranchEventAdType.BANNER; + eventStandard.addCustomData('Custom_Event_Property_Key1', 'Custom_Event_Property_val1'); + eventStandard.addCustomData('Custom_Event_Property_Key2', 'Custom_Event_Property_val2'); + FlutterBranchSdk.trackContent(buo: [buo], branchEvent: eventStandard); ``` `trackContent` accepts a list of Branch Universal Object. diff --git a/android/build.gradle b/android/build.gradle index dad11ea6..d45c87ff 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -35,7 +35,7 @@ android { } dependencies { - implementation 'io.branch.sdk.android:library:5.2.+' + implementation 'io.branch.sdk.android:library:5.4.+' implementation 'com.google.firebase:firebase-appindexing:19.0.0' implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1+' implementation 'androidx.browser:browser:1.4.0' diff --git a/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkPlugin.java b/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkPlugin.java index 6614336d..ad60294f 100644 --- a/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkPlugin.java +++ b/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkPlugin.java @@ -315,6 +315,10 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result rawResult) { case "setPreinstallPartner" : setPreinstallPartner(call); break; + case "addSnapPartnerParameter" : + addSnapPartnerParameter(call); + break; + default: result.notImplemented(); break; @@ -844,6 +848,21 @@ public void run() { } }); } + private void addSnapPartnerParameter(MethodCall call) { + LogUtils.debug(DEBUG_NAME, "addSnapPartnerParameter call"); + if (!(call.arguments instanceof Map)) { + throw new IllegalArgumentException("Map argument expected"); + } + final String key = call.argument("key"); + final String value = call.argument("value"); + + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + Branch.getAutoInstance(context).addSnapPartnerParameterWithName(key, value); + } + }); + } } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 4f8c1534..e978fe1a 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,8 +1,8 @@ PODS: - - BranchSDK (2.0.0) + - BranchSDK (2.1.0) - Flutter (1.0.0) - flutter_branch_sdk (6.4.0): - - BranchSDK (~> 2.0.0) + - BranchSDK (~> 2.1.0) - Flutter DEPENDENCIES: @@ -20,9 +20,9 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_branch_sdk/ios" SPEC CHECKSUMS: - BranchSDK: dbecf9d1da931c2cf57393b233347b3587d11acb + BranchSDK: ce28650272c658fcdb66675769e670ef83845d17 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - flutter_branch_sdk: 193591ad0c4938b925c9068aff19584236c3cf8f + flutter_branch_sdk: cc0393df011973fe6ab0380bc54bce1a3726e8a3 PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 194eb1be..8575af35 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -203,6 +203,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -239,6 +240,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index f986b2c3..6b1d6627 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -68,5 +68,7 @@ branch_key key_test_ipQTteg11ENANDeCzSXgqdgfuycWoXYH + UIApplicationSupportsIndirectInputEvents + diff --git a/example/lib/main.dart b/example/lib/main.dart index 44796dff..ac285077 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -12,9 +12,17 @@ void main() { WidgetsFlutterBinding.ensureInitialized(); //FlutterBranchSdk.setPreinstallCampaign('My Campaign Name'); //FlutterBranchSdk.setPreinstallPartner('Branch \$3p Parameter Value'); - //FlutterBranchSdk.addFacebookPartnerParameter('em', '11234e56af071e9c79927651156bd7a10bca8ac34672aba121056e2698ee7088'); + + //FlutterBranchSdk.addFacebookPartnerParameter( + // key: 'em', + // value: '11234e56af071e9c79927651156bd7a10bca8ac34672aba121056e2698ee7088'); //FlutterBranchSdk.clearPartnerParameters(); + //FlutterBranchSdk.addSnapPartnerParameter( + // key: 'hashed_email_address', + // value: + // '11234e56af071e9c79927651156bd7a10bca8ac34672aba121056e2698ee7088'); + runApp(const MyApp()); } @@ -45,7 +53,7 @@ class _HomePageState extends State { BranchContentMetaData metadata = BranchContentMetaData(); BranchUniversalObject? buo; BranchLinkProperties lp = BranchLinkProperties(); - BranchEvent? eventStandart; + BranchEvent? eventStandard; BranchEvent? eventCustom; StreamSubscription? streamSubscription; @@ -183,7 +191,7 @@ class _HomePageState extends State { ..addControlParam('\$android_redirect_timeout', 750) ..addControlParam('referring_user_id', 'user_id'); - eventStandart = BranchEvent.standardEvent(BranchStandardEvent.ADD_TO_CART) + eventStandard = BranchEvent.standardEvent(BranchStandardEvent.ADD_TO_CART) //--optional Event data ..transactionID = '12344555' ..currency = BranchCurrencyType.BRL @@ -256,11 +264,11 @@ class _HomePageState extends State { } void trackContent() { - FlutterBranchSdk.trackContent(buo: [buo!], branchEvent: eventStandart!); + FlutterBranchSdk.trackContent(buo: [buo!], branchEvent: eventStandard!); FlutterBranchSdk.trackContent(buo: [buo!], branchEvent: eventCustom!); - FlutterBranchSdk.trackContentWithoutBuo(branchEvent: eventStandart!); + FlutterBranchSdk.trackContentWithoutBuo(branchEvent: eventStandard!); FlutterBranchSdk.trackContentWithoutBuo(branchEvent: eventCustom!); diff --git a/ios/Classes/SwiftFlutterBranchSdkPlugin.swift b/ios/Classes/SwiftFlutterBranchSdkPlugin.swift index a53e46f3..ac95f91e 100644 --- a/ios/Classes/SwiftFlutterBranchSdkPlugin.swift +++ b/ios/Classes/SwiftFlutterBranchSdkPlugin.swift @@ -244,6 +244,9 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream case "setPreinstallPartner" : setPreinstallPartner(call: call) break + case "addSnapPartnerParameter" : + addSnapPartnerParameter(call: call) + break default: result(FlutterMethodNotImplemented) break @@ -591,7 +594,17 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream Branch.getInstance().addFacebookPartnerParameter(withName: key, value:value) } } - + + private func addSnapPartnerParameter(call: FlutterMethodCall) { + let args = call.arguments as! [String: Any?] + let key = args["key"] as! String + let value = args["value"] as! String + + DispatchQueue.main.async { + Branch.getInstance().addSnapPartnerParameter(withName: key, value:value) + } + } + private func setPreinstallCampaign(call: FlutterMethodCall) { } diff --git a/ios/flutter_branch_sdk.podspec b/ios/flutter_branch_sdk.podspec index b9cfc8a2..accc759e 100644 --- a/ios/flutter_branch_sdk.podspec +++ b/ios/flutter_branch_sdk.podspec @@ -15,7 +15,7 @@ Flutter Plugin for create deep link using Brach SDK (https://branch.io). This pl s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.dependency 'Flutter' - s.dependency 'BranchSDK', '~> 2.0.0' + s.dependency 'BranchSDK', '~> 2.1.0' s.platform = :ios, '9.0' # Flutter.framework does not contain a i386 slice. diff --git a/lib/src/flutter_branch_sdk.dart b/lib/src/flutter_branch_sdk.dart index 5828139f..5aedb189 100644 --- a/lib/src/flutter_branch_sdk.dart +++ b/lib/src/flutter_branch_sdk.dart @@ -213,8 +213,10 @@ class FlutterBranchSdk { /// Add a Partner Parameter for Facebook. /// Once set, this parameter is attached to installs, opens and events until cleared or the app restarts. /// See Facebook's documentation for details on valid parameters - static void addFacebookPartnerParameter(String key, String value) { - FlutterBranchSdkPlatform.instance.addFacebookPartnerParameter(key, value); + static void addFacebookPartnerParameter( + {required String key, required String value}) { + FlutterBranchSdkPlatform.instance + .addFacebookPartnerParameter(key: key, value: value); } /// Clears all Partner Parameters @@ -231,4 +233,12 @@ class FlutterBranchSdk { static void setPreinstallPartner(String value) { FlutterBranchSdkPlatform.instance.setPreinstallPartner(value); } + + ///Add a Partner Parameter for Snap. + ///Once set, this parameter is attached to installs, opens and events until cleared or the app restarts. + static void addSnapPartnerParameter( + {required String key, required String value}) { + FlutterBranchSdkPlatform.instance + .addSnapPartnerParameter(key: key, value: value); + } } diff --git a/lib/src/flutter_branch_sdk_method_channel.dart b/lib/src/flutter_branch_sdk_method_channel.dart index 917e747f..2c12bc7e 100644 --- a/lib/src/flutter_branch_sdk_method_channel.dart +++ b/lib/src/flutter_branch_sdk_method_channel.dart @@ -348,7 +348,8 @@ class FlutterBranchSdkMethodChannel implements FlutterBranchSdkPlatform { /// Once set, this parameter is attached to installs, opens and events until cleared or the app restarts. /// See Facebook's documentation for details on valid parameters @override - void addFacebookPartnerParameter(String key, String value) { + void addFacebookPartnerParameter( + {required String key, required String value}) { messageChannel.invokeMethod( 'addFacebookPartnerParameter', {'key': key, 'value': value}); } @@ -370,4 +371,12 @@ class FlutterBranchSdkMethodChannel implements FlutterBranchSdkPlatform { void setPreinstallPartner(String value) { messageChannel.invokeMethod('setPreinstallPartner', {'value': value}); } + + ///Add a Partner Parameter for Snap. + ///Once set, this parameter is attached to installs, opens and events until cleared or the app restarts. + @override + void addSnapPartnerParameter({required String key, required String value}) { + messageChannel + .invokeMethod('addSnapPartnerParameter', {'key': key, 'value': value}); + } } diff --git a/lib/src/flutter_branch_sdk_platform_interface.dart b/lib/src/flutter_branch_sdk_platform_interface.dart index fe4e89ea..45e9c8ea 100644 --- a/lib/src/flutter_branch_sdk_platform_interface.dart +++ b/lib/src/flutter_branch_sdk_platform_interface.dart @@ -238,7 +238,8 @@ abstract class FlutterBranchSdkPlatform extends PlatformInterface { /// Add a Partner Parameter for Facebook. /// Once set, this parameter is attached to installs, opens and events until cleared or the app restarts. /// See Facebook's documentation for details on valid parameters - void addFacebookPartnerParameter(String key, String value) { + void addFacebookPartnerParameter( + {required String key, required String value}) { throw UnimplementedError( 'addFacebookPartnerParameter has not been implemented'); } @@ -247,4 +248,11 @@ abstract class FlutterBranchSdkPlatform extends PlatformInterface { void clearPartnerParameters() { throw UnimplementedError('clearPartnerParameters has not been implemented'); } + + ///Add a Partner Parameter for Snap. + ///Once set, this parameter is attached to installs, opens and events until cleared or the app restarts. + void addSnapPartnerParameter({required String key, required String value}) { + throw UnimplementedError( + 'addSnapPartnerParameter has not been implemented'); + } } diff --git a/lib/src/flutter_branch_sdk_web.dart b/lib/src/flutter_branch_sdk_web.dart index f72c98b9..902a7197 100644 --- a/lib/src/flutter_branch_sdk_web.dart +++ b/lib/src/flutter_branch_sdk_web.dart @@ -461,7 +461,8 @@ class FlutterBranchSdkWeb extends FlutterBranchSdkPlatform { /// Once set, this parameter is attached to installs, opens and events until cleared or the app restarts. /// See Facebook's documentation for details on valid parameters @override - void addFacebookPartnerParameter(String key, String value) { + void addFacebookPartnerParameter( + {required String key, required String value}) { throw UnsupportedError( 'addFacebookPartnerParameter() Not available in Branch JS SDK'); } @@ -487,6 +488,14 @@ class FlutterBranchSdkWeb extends FlutterBranchSdkPlatform { 'setPreinstallPartner() Not available in Branch JS SDK'); } + ///Add a Partner Parameter for Snap. + ///Once set, this parameter is attached to installs, opens and events until cleared or the app restarts. + @override + void addSnapPartnerParameter({required String key, required String value}) { + throw UnsupportedError( + 'addSnapPartnerParameter() Not available in Branch JS SDK'); + } + void close() { _initSessionStream.close(); }