Skip to content

Commit

Permalink
Release 7.0.3
Browse files Browse the repository at this point in the history
### Issues

* Fix issue #277 : PlatformException - NullPointerException

### Features
* PR #286 : fix: export platform_interface
* Updated configuration steps in README.MD
* Sample app - code review
  • Loading branch information
RodrigoSMarques committed Feb 1, 2024
1 parent b904047 commit 155a516
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 46 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 7.0.3
### Issues

* Fix issue #277 : PlatformException - NullPointerException

### Features
* PR #286 : fix: export platform_interface
* Updated configuration steps in README.MD
* Sample app - code review

## 7.0.2
### Issues

Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,29 @@ Handle Links in Your Own App| X | X | X
## Getting Started
### Configure Branch Dashboard
* Register Your App
* Complete the Basic integration in [Branch Dashboard](https://dashboard.branch.io/login)
* Configure Branch Dashboard [Branch Dashboard](https://dashboard.branch.io/login)

For details see:

* [iOS - only section: **Configure Branch**](https://help.branch.io/developers-hub/docs/ios-basic-integration#configure-branch)
* [Android - only section: **Configure Branch Dashboard**](https://help.branch.io/developers-hub/docs/android-basic-integration#configure-branch-dashboard)
* [iOS: only section: **Configure Branch Dashboard**](https://help.branch.io/developers-hub/docs/ios-basic-integration#1-configure-branch-dashboard)
* [Android - only section: **Configure Branch Dashboard**](https://help.branch.io/developers-hub/docs/android-basic-integration#1-configure-branch-dashboard)

## Configure Platform Project
### Android Integration

Follow the steps on the page [https://help.branch.io/developers-hub/docs/android-basic-integration#configure-app](https://help.branch.io/developers-hub/docs/android-basic-integration#configure-app), session _**Configure app**_:
Follow the steps:

* Add Branch to your `AndroidManifest.xml`
* [Configure App](https://help.branch.io/developers-hub/docs/android-basic-integration#4-configure-app)
* [Configure ProGuard](https://help.branch.io/developers-hub/docs/android-basic-integration#7-configure-proguard)

-

### iOS Integration
Follow the steps on the page [https://help.branch.io/developers-hub/docs/ios-basic-integration#configure-bundle-identifier](https://help.branch.io/developers-hub/docs/ios-basic-integration#configure-bundle-identifier), from session ```Configure bundle identifier```:
Follow the steps:

* Configure bundle identifier
* Configure associated domains
* Configure Info.plist
* [Configure bundle identifier](https://help.branch.io/developers-hub/docs/ios-basic-integration#2-configure-bundle-identifier)
* [Configure associated domains](https://help.branch.io/developers-hub/docs/ios-basic-integration#3-configure-associated-domains)
* [Configure Info.plist](https://help.branch.io/developers-hub/docs/ios-basic-integration#4-configure-infoplist)

#### NativeLink™ Deferred Deep Linking
Use iOS pasteboard to enable deferred deep linking via Branch NativeLink™, which enables 100% matching on iOS through Installs.
Expand Down
6 changes: 6 additions & 0 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ public void onActivityCreated(@NonNull Activity activity, Bundle bundle) {
public void onActivityStarted(@NonNull Activity activity) {
LogUtils.debug(DEBUG_NAME, "triggered onActivityStarted");
if (!isInitialized) {
// Delay session initialization
Branch.expectDelayedSessionInitialization(true);
return;
}
LogUtils.debug(DEBUG_NAME, "triggered SessionBuilder init");
Expand Down Expand Up @@ -374,6 +376,7 @@ private void setupBranch(MethodCall call, final Result result) {
if (isInitialized) {
result.success(Boolean.TRUE);
}

HashMap<String, Object> argsMap = (HashMap<String, Object>) call.arguments;
if ((Boolean) argsMap.get("useTestKey")) {
Branch.enableTestMode();
Expand Down Expand Up @@ -433,6 +436,13 @@ private void setupBranch(MethodCall call, final Result result) {
Branch.getInstance().disableTracking(true);
}
isInitialized = true;

if (this.activity == null) {
initialIntent = null;
result.success(Boolean.TRUE);
return;
}

if (initialIntent == null) {
initialIntent = new Intent(this.context, this.activity.getClass());
initialIntent.setAction(Intent.ACTION_MAIN);
Expand Down
42 changes: 22 additions & 20 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_branch_sdk/flutter_branch_sdk.dart';
import 'package:uuid/uuid.dart';

import 'custom_button.dart';

Expand Down Expand Up @@ -80,8 +81,6 @@ class _HomePageState extends State<HomePage> {

initDeepLinkData();

FlutterBranchSdk.setIdentity('branch_user_test');

//requestATTTracking();
}

Expand Down Expand Up @@ -146,8 +145,6 @@ class _HomePageState extends State<HomePage> {
final DateTime today = DateTime.now();
String dateString =
'${today.year}-${today.month}-${today.day} ${today.hour}:${today.minute}:${today.second}';
String dateKey =
'${today.year}${today.month}${today.day}_${today.hour}${today.minute}${today.second}';

metadata = BranchContentMetaData()
..addCustomMetadata('custom_string', 'abcd')
Expand Down Expand Up @@ -180,25 +177,19 @@ class _HomePageState extends State<HomePage> {
postalCode: '99999-987')
..setLocation(31.4521685, -114.7352207);
*/

final canonicalIdentifier = const Uuid().v4();
buo = BranchUniversalObject(
canonicalIdentifier: 'flutter/branch_$dateKey',
canonicalIdentifier: 'flutter/branch_$canonicalIdentifier',
//parameter canonicalUrl
//If your content lives both on the web and in the app, make sure you set its canonical URL
// (i.e. the URL of this piece of content on the web) when building any BUO.
// By doing so, we’ll attribute clicks on the links that you generate back to their original web page,
// even if the user goes to the app instead of your website! This will help your SEO efforts.
canonicalUrl: 'https://flutter.dev',
//canonicalUrl: 'https://flutter.dev',
title: 'Flutter Branch Plugin - $dateString',
imageUrl: imageURL,
contentDescription: 'Flutter Branch Description - $dateString',
/*
contentMetadata: BranchContentMetaData()
..addCustomMetadata('custom_string', 'abc')
..addCustomMetadata('custom_number', 12345)
..addCustomMetadata('custom_bool', true)
..addCustomMetadata('custom_list_number', [1, 2, 3, 4, 5])
..addCustomMetadata('custom_list_string', ['a', 'b', 'c']),
*/
contentMetadata: metadata,
keywords: ['Plugin', 'Branch', 'Flutter'],
publiclyIndex: true,
Expand Down Expand Up @@ -254,7 +245,7 @@ class _HomePageState extends State<HomePage> {
'Custom_Event_Property_Key2', 'Custom_Event_Property_val2');
}

void showSnackBar({required String message, int duration = 1}) {
void showSnackBar({required String message, int duration = 2}) {
scaffoldMessengerKey.currentState!.removeCurrentSnackBar();
scaffoldMessengerKey.currentState!.showSnackBar(
SnackBar(
Expand Down Expand Up @@ -287,14 +278,25 @@ class _HomePageState extends State<HomePage> {
showSnackBar(message: 'Tracking disabled');
}

void identifyUser() {
FlutterBranchSdk.setIdentity('branch_user_test');
showSnackBar(message: 'User branch_user_test identfied');
void identifyUser() async {
final isUserIdentified = await FlutterBranchSdk.isUserIdentified();
if (isUserIdentified) {
showSnackBar(message: 'User logged in');
return;
}
final userId = const Uuid().v4();
FlutterBranchSdk.setIdentity(userId);
showSnackBar(message: 'User identified: $userId');
}

void userLogout() {
void userLogout() async {
final isUserIdentified = await FlutterBranchSdk.isUserIdentified();
if (!isUserIdentified) {
showSnackBar(message: 'No users logged in');
return;
}
FlutterBranchSdk.logout();
showSnackBar(message: 'User branch_user_test logout');
showSnackBar(message: 'User logout');
}

void registerView() {
Expand Down
42 changes: 41 additions & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -57,6 +65,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.1"
fixnum:
dependency: transitive
description:
name: fixnum
sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -68,7 +84,7 @@ packages:
path: ".."
relative: true
source: path
version: "7.0.2"
version: "7.0.3"
flutter_lints:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -156,6 +172,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.0"
sprintf:
dependency: transitive
description:
name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -196,6 +220,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.1"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
uuid:
dependency: "direct main"
description:
name: uuid
sha256: cd210a09f7c18cbe5a02511718e0334de6559871052c90a90c0cca46a4aa81c8
url: "https://pub.dev"
source: hosted
version: "4.3.3"
vector_math:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ dependencies:

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
cupertino_icons: ^1.0.6
uuid: ^4.3.3

dev_dependencies:
flutter_test:
Expand Down
26 changes: 13 additions & 13 deletions ios/Classes/SwiftFlutterBranchSdkPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
var requestMetadata : [String: String] = [:]
var facebookParameters : [String: String] = [:]
var snapParameters : [String: String] = [:]

//---------------------------------------------------------------------------------------------
// Plugin registry
// --------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -157,7 +157,7 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
break
case "setRequestMetadata":
setRequestMetadata(call: call);
break;
break
case "logout":
logout()
break
Expand Down Expand Up @@ -238,13 +238,13 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
if let _ = branch {
result(true)
}

let args = call.arguments as! [String: Any?]

#if DEBUG
NSLog("setupBranch args: %@", args)
#endif

if args["useTestKey"] as! Bool == true {
Branch.setUseTestBranchKey(true)
}
Expand All @@ -256,7 +256,7 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
branch = Branch.getInstance()

branch!.registerPluginName(PLUGIN_NAME, version: args["version"] as! String)

#if DEBUG
if args["enableLogging"] as! Bool == true {
branch!.enableLogging()
Expand All @@ -267,7 +267,7 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
if #available(iOS 15, *) {
branch!.checkPasteboardOnInstall()
}

if (!requestMetadata.isEmpty) {
for param in requestMetadata {
Branch.getInstance().setRequestMetadataKey(param.key, value: param.value)
Expand All @@ -283,7 +283,7 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
Branch.getInstance().addFacebookPartnerParameter(withName: param.key, value: param.value)
}
}

branch!.initSession(launchOptions: initialLaunchOptions) { (params, error) in
if error == nil {
print("Branch InitSession params: \(String(describing: params as? [String: Any]))")
Expand Down Expand Up @@ -500,7 +500,7 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
}
return;
}

DispatchQueue.main.async {
self.branch!.setRequestMetadataKey(key, value: value)
}
Expand Down Expand Up @@ -564,7 +564,7 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
}
}
}

private func isUserIdentified(result: @escaping FlutterResult) {
DispatchQueue.main.async {
result(self.branch!.isUserIdentified())
Expand Down Expand Up @@ -676,7 +676,7 @@ 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
Expand All @@ -690,12 +690,12 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream
}
return;
}

DispatchQueue.main.async {
Branch.getInstance().addSnapPartnerParameter(withName: key, value:value)
}
}

private func setPreinstallCampaign(call: FlutterMethodCall) {
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/flutter_branch_sdk_method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'objects/branch_universal_object.dart';

/// An implementation of [FlutterBranchSdkPlatform] that uses method channels.
class FlutterBranchSdkMethodChannel implements FlutterBranchSdkPlatform {
static const PLUGIN_VERSION = "7.0.2";
static const PLUGIN_VERSION = "7.0.3";
static const MESSAGE_CHANNEL = 'flutter_branch_sdk/message';
static const EVENT_CHANNEL = 'flutter_branch_sdk/event';

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_branch_sdk
description: Flutter Plugin for create deep link using Brach SDK (https://branch.io). This plugin provides a cross-platform (iOS, Android, Web).
version: 7.0.2
version: 7.0.3
homepage: https://github.com/RodrigoSMarques/flutter_branch_sdk

environment:
Expand Down

0 comments on commit 155a516

Please sign in to comment.