Skip to content

Commit

Permalink
Merge pull request #157 from RodrigoSMarques/dev
Browse files Browse the repository at this point in the history
Version 5.1.0
  • Loading branch information
RodrigoSMarques authored May 27, 2022
2 parents 6a3e835 + e2d3c9f commit 0dbc702
Show file tree
Hide file tree
Showing 19 changed files with 354 additions and 101 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 5.1.0
* Fix issue #143: Infinite loop with POST requests when offline
* Fix issue #146: clicked_branch_link is to true when app is opened from deeplink and then putted in background and reopened
* Fix issue #113: Fatal Exception: java.lang.IllegalStateException Reply already submitted
* New Method `getLastAttributedTouchData`
* Updated Native `Android` and `iOS` SDKs:
* Android Native SDK Update 5.1.4 - [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases)
* iOS Native SDK Update 1.42.0 - [iOS Version History](https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/releases)

## 5.0.0
**BREAKING CHANGE**:

Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,23 @@ By default, Branch limits calls to SKAdNetwork to within 72 hours after first in
FlutterBranchSdk.setIOSSKAdNetworkMaxTime(24);
```

### Retrieve Branch's Last Attributed Touch Data

Allow retrieval of our last attributed touch data (LATD) from the client. This results in an asynchronous call being made to Branch’s servers with LATD data returned when possible.

Last attributed touch data contains the information associated with that user's last viewed impression or clicked link.


```dart
BranchResponse response =
await FlutterBranchSdk.getLastAttributedTouchData();
if (response.success) {
print(response.result.toString());
}
```

More information [here](https://help.branch.io/developers-hub/docs/retrieving-branchs-last-attributed-touch-data).

### Apple Search Ads
Branch can help track your Apple Search Ad campaigns by fetching the search ad attribution from Apple at app install.

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
}

dependencies {
implementation 'io.branch.sdk.android:library:5.1.0'
implementation 'io.branch.sdk.android:library:5.1.4'
implementation 'com.google.firebase:firebase-appindexing:19.0.0'
implementation 'com.google.android.gms:play-services-ads-identifier:17.1.0+'
implementation 'androidx.browser:browser:1.4.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

public class FlutterBranchSdkInit {
private static final String DEBUG_NAME = "FlutterBranchSDK";
private static final String PLUGIN_NAME = "Flutter";
private static final String PLUGIN_VERSION = "5.1.0";

public static void init(Context context) {
ApplicationInfoHelper applicationInfoHelper = new ApplicationInfoHelper(context);
Expand All @@ -23,6 +25,7 @@ public static void init(Context context) {
}

// Branch object initialization
Branch.registerPlugin(PLUGIN_NAME, PLUGIN_VERSION);
Branch.getAutoInstance(context);
}
}

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-keep class com.google.android.gms.ads.identifier.** { *; }

-keep class com.google.android.gms.* {*;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PODS:
- Branch (1.41.0)
- Branch (1.42.0)
- Flutter (1.0.0)
- flutter_branch_sdk (3.0.0):
- Branch (~> 1.41.0)
- Branch (~> 1.42.0)
- Flutter

DEPENDENCIES:
Expand All @@ -20,10 +20,10 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_branch_sdk/ios"

SPEC CHECKSUMS:
Branch: bd6c472d6cab03206877ac86c1241327a3f217d1
Branch: a6f1d597dc7c027360f386d05e8d109043b207d8
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
flutter_branch_sdk: 2ec9991f1bcbae27d7d2e344b86b8b49a6e64b72
flutter_branch_sdk: ecb5dd985a092ef5aecc9195c6645649e6ea1b9f

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c

COCOAPODS: 1.11.2
COCOAPODS: 1.11.3
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@
<true/>
<key>branch_enable_facebook_ads</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
21 changes: 20 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ class _HomePageState extends State<HomePage> {
),
],
),
CustomButton(
child: Text('Get last Attributed'),
onPressed: getLastAttributed,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expand Down Expand Up @@ -534,7 +538,22 @@ class _HomePageState extends State<HomePage> {

if (response.success) {
showSnackBar(
context: context, message: 'showShareSheet Sucess', duration: 5);
context: context, message: 'showShareSheet Success', duration: 5);
} else {
showSnackBar(
context: context,
message:
'showShareSheet Error: ${response.errorCode} - ${response.errorMessage}',
duration: 5);
}
}

void getLastAttributed() async {
BranchResponse response =
await FlutterBranchSdk.getLastAttributedTouchData();
if (response.success) {
showSnackBar(
context: context, message: response.result.toString(), duration: 5);
} else {
showSnackBar(
context: context,
Expand Down
27 changes: 10 additions & 17 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -56,7 +56,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -68,7 +68,7 @@ packages:
path: ".."
relative: true
source: path
version: "5.0.0"
version: "5.1.0"
flutter_lints:
dependency: transitive
description:
Expand All @@ -92,7 +92,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
version: "0.6.4"
lints:
dependency: transitive
description:
Expand All @@ -113,7 +113,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -127,7 +127,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
plugin_platform_interface:
dependency: transitive
description:
Expand All @@ -146,7 +146,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -181,21 +181,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=1.22.0"
63 changes: 51 additions & 12 deletions ios/Classes/SwiftFlutterBranchSdkPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ var methodChannel: FlutterMethodChannel?
var eventChannel: FlutterEventChannel?
let MESSAGE_CHANNEL = "flutter_branch_sdk/message";
let EVENT_CHANNEL = "flutter_branch_sdk/event";
let ERROR_CODE = "FLUTTER_BRANCH_SDK_ERROR"
let ERROR_CODE = "FLUTTER_BRANCH_SDK_ERROR";
let PLUGIN_NAME = "Flutter";
let PLUGIN_VERSION = "5.1.0"

public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStreamHandler {
var eventSink: FlutterEventSink?
Expand All @@ -29,19 +31,23 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
registrar.addMethodCallDelegate(instance, channel: methodChannel!)
}


public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [AnyHashable : Any] = [:]) -> Bool {

#if DEBUG


Branch.getInstance().registerPluginName(PLUGIN_NAME, version: PLUGIN_VERSION);

#if DEBUG
let enableLog = Bundle.infoPlistValue(forKey: "branch_enable_log") as? Bool ?? true
if enableLog {
Branch.getInstance().enableLogging()
}
#else
#else
let enableLog = Bundle.infoPlistValue(forKey: "branch_enable_log") as? Bool ?? false
if enableLog {
Branch.getInstance().enableLogging()
}
#endif
#endif

let enableAppleADS = Bundle.infoPlistValue(forKey: "branch_check_apple_ads") as? Bool ?? false

Expand Down Expand Up @@ -69,7 +75,7 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream

let checkPasteboard = Bundle.infoPlistValue(forKey: "branch_check_pasteboard") as? Bool ?? false
print("Branch Clipboard Deferred Deep Linking: \(String(describing:checkPasteboard))");

if checkPasteboard {
Branch.getInstance().checkPasteboardOnInstall()
}
Expand Down Expand Up @@ -221,8 +227,12 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
case "setTimeout":
setTimeout(call: call)
break
case "getLastAttributedTouchData":
getLastAttributedTouchData(call: call, result: result)
break
default:
result(FlutterMethodNotImplemented)
break
}
}

Expand Down Expand Up @@ -262,7 +272,7 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
let shareText = args["messageText"] as! String
let buo: BranchUniversalObject? = convertToBUO(dict: buoDict)
let lp : BranchLinkProperties? = convertToLp(dict: lpDict )
let controller = UIApplication.shared.keyWindow!.rootViewController as! FlutterViewController
let controller = UIApplication.shared.keyWindow!.rootViewController

let response : NSMutableDictionary! = [:]
buo?.showShareSheet(with: lp, andShareText: shareText, from: controller) { (activityType, completed, error) in
Expand Down Expand Up @@ -392,7 +402,6 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
DispatchQueue.main.async {
Branch.getInstance().setRequestMetadataKey(key, value: value)
}

}

private func logout() {
Expand Down Expand Up @@ -532,6 +541,35 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
}
}

private func getLastAttributedTouchData(call: FlutterMethodCall, result: @escaping FlutterResult) {

let args = call.arguments as! [String: Any?]
let response : NSMutableDictionary! = [:]
let data : NSMutableDictionary! = [:]
let attributionWindow = args["attributionWindow"] as? Int ?? 0

Branch.getInstance().lastAttributedTouchData(withAttributionWindow: attributionWindow) { latd, error in
if error == nil {
if latd != nil {
data["latd"] = latd
} else {
data["latd"] = [:]
}
response["success"] = NSNumber(value: true)
response["data"] = data
} else {
print("Failed to lastAttributedTouchData: \(String(describing: error))")
let err = (error! as NSError)
response["success"] = NSNumber(value: false)
response["errorCode"] = String(err.code)
response["errorMessage"] = err.localizedDescription
}
DispatchQueue.main.async {
result(response)
}
}
}

private func setSKAdNetworkMaxTime(call: FlutterMethodCall) {
let args = call.arguments as! [String: Any?]
let maxTimeInterval = args["maxTimeInterval"] as? Int ?? 0
Expand Down Expand Up @@ -598,11 +636,12 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
}
}
}

private func setTimeout(call: FlutterMethodCall) {
let args = call.arguments as! [String: Any?]
let timeout = args["timeout"] as? Int ?? 0
let _ = args["timeout"] as? Int ?? 0
}

private func setConnectTimeout(call: FlutterMethodCall) {
let args = call.arguments as! [String: Any?]
let connectTimeout = args["connectTimeout"] as? Int ?? 0
Expand All @@ -613,9 +652,9 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream

private func setRetryCount(call: FlutterMethodCall) {
let args = call.arguments as! [String: Any?]
let retryCount = args["retryCount"] as? Int ?? 0
let _ = args["retryCount"] as? Int ?? 0
}

private func setRetryInterval(call: FlutterMethodCall) {
let args = call.arguments as! [String: Any?]
let retryInterval = args["retryInterval"] as? Int ?? 0
Expand Down
2 changes: 1 addition & 1 deletion ios/flutter_branch_sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Flutter Plugin for Brach Metrics SDK - https:&#x2F;&#x2F;branch.io
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.dependency 'Branch', '~> 1.41.0'
s.dependency 'Branch', '~> 1.42.0'
s.platform = :ios, '9.0'

# Flutter.framework does not contain a i386 slice.
Expand Down
Loading

0 comments on commit 0dbc702

Please sign in to comment.