Skip to content

Commit

Permalink
Merge pull request #288 from RodrigoSMarques/dev
Browse files Browse the repository at this point in the history
Release 7.0.3
  • Loading branch information
RodrigoSMarques committed Feb 1, 2024
2 parents ba34182 + 155a516 commit 65acf63
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 70 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
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Branch.io helps mobile apps grow with deep links that power referral systems, sh

Supports Android, iOS and Web.

* Android - Branch SDK Version >= 5.7.+ [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases)
* Android - Branch SDK Version >= 5.8.+ [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases)
* iOS - Branch SDK Version >= 3.0.+ [iOS Version History](https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/releases)

Implemented functions in plugin:
Expand All @@ -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
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
BranchSDK: e9c0332b2655cf0357d93db479d07152b059e434
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_branch_sdk: 074b3a7e9c8214c3f19c1b72840c114abb641b06

PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -425,7 +425,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -474,7 +474,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
75 changes: 47 additions & 28 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 @@ -124,29 +123,38 @@ class _HomePageState extends State<HomePage> {
data['+clicked_branch_link'] == true) {
print(
'------------------------------------Link clicked----------------------------------------------');
print('Title: ${data['\$og_title']}');
print('Custom string: ${data['custom_string']}');
print('Custom number: ${data['custom_number']}');
print('Custom bool: ${data['custom_bool']}');
print('Custom date: ${data['custom_date_created']}');
print('Custom list number: ${data['custom_list_number']}');
print(
'------------------------------------------------------------------------------------------------');
showSnackBar(
message: 'Link clicked: Custom string - ${data['custom_string']}',
message:
'Link clicked: Custom string - ${data['custom_string']} - Date: ${data['custom_date_created'] ?? ''}',
duration: 10);
}
}, onError: (error) {
print('listSesseion error: ${error.toString()}');
print('listSession error: ${error.toString()}');
});
}

void initDeepLinkData() {
final DateTime today = DateTime.now();
String dateString =
'${today.year}-${today.month}-${today.day} ${today.hour}:${today.minute}:${today.second}';

metadata = BranchContentMetaData()
..addCustomMetadata('custom_string', 'abcd')
..addCustomMetadata('custom_number', 12345)
..addCustomMetadata('custom_bool', true)
..addCustomMetadata('custom_list_number', [1, 2, 3, 4, 5])
..addCustomMetadata('custom_list_string', ['a', 'b', 'c'])
//--optional Custom Metadata
..addCustomMetadata('custom_date_created', dateString);
//--optional Custom Metadata
/*
..contentSchema = BranchContentSchema.COMMERCE_PRODUCT
..price = 50.99
..currencyType = BranchCurrencyType.BRL
Expand All @@ -168,42 +176,36 @@ class _HomePageState extends State<HomePage> {
country: 'Brazil',
postalCode: '99999-987')
..setLocation(31.4521685, -114.7352207);
*/

final canonicalIdentifier = const Uuid().v4();
buo = BranchUniversalObject(
canonicalIdentifier: 'flutter/branch',
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',
title: 'Flutter Branch Plugin',
//canonicalUrl: 'https://flutter.dev',
title: 'Flutter Branch Plugin - $dateString',
imageUrl: imageURL,
contentDescription: 'Flutter Branch Description',
/*
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']),
*/
contentDescription: 'Flutter Branch Description - $dateString',
contentMetadata: metadata,
keywords: ['Plugin', 'Branch', 'Flutter'],
publiclyIndex: true,
locallyIndex: true,
expirationDateInMilliSec: DateTime.now()
.add(const Duration(days: 365))
.millisecondsSinceEpoch);

lp = BranchLinkProperties(
channel: 'facebook',
channel: 'share',
feature: 'sharing',
//parameter alias
//Instead of our standard encoded short url, you can specify the vanity alias.
// For example, instead of a random string of characters/integers, you can set the vanity alias as *.app.link/devonaustin.
// Aliases are enforced to be unique** and immutable per domain, and per link - they cannot be reused unless deleted.
//alias: 'https://branch.io' //define link url,
//alias: 'p/$id', //define link url,
stage: 'new share',
campaign: 'campaign',
tags: ['one', 'two', 'three'])
Expand All @@ -212,7 +214,10 @@ class _HomePageState extends State<HomePage> {
..addControlParam('\$match_duration', 7200)
..addControlParam('\$always_deeplink', true)
..addControlParam('\$android_redirect_timeout', 750)
..addControlParam('referring_user_id', 'user_id');
..addControlParam('referring_user_id', 'user_id') //;
..addControlParam('\$ios_url', 'https://flutter-branch-sdk.netlify.app/')
..addControlParam(
'\$android_url', 'https://flutter-branch-sdk.netlify.app/');

eventStandard = BranchEvent.standardEvent(BranchStandardEvent.ADD_TO_CART)
//--optional Event data
Expand Down Expand Up @@ -240,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 @@ -273,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 Expand Up @@ -358,6 +374,7 @@ class _HomePageState extends State<HomePage> {
}

void generateLink(BuildContext context) async {
initDeepLinkData();
BranchResponse response =
await FlutterBranchSdk.getShortUrl(buo: buo, linkProperties: lp);
if (response.success) {
Expand Down Expand Up @@ -389,8 +406,8 @@ class _HomePageState extends State<HomePage> {
print(
'Error : ${responseQrCodeData.errorCode} - ${responseQrCodeData.errorMessage}');
}
*/
initDeepLinkData();
BranchResponse responseQrCodeImage =
await FlutterBranchSdk.getQRCodeAsImage(
buo: buo,
Expand All @@ -413,6 +430,7 @@ class _HomePageState extends State<HomePage> {
}

void showGeneratedLink(BuildContext context, String url) async {
initDeepLinkData();
showModalBottomSheet(
isDismissible: true,
isScrollControlled: true,
Expand Down Expand Up @@ -505,6 +523,7 @@ class _HomePageState extends State<HomePage> {
}

void shareLink() async {
initDeepLinkData();
BranchResponse response = await FlutterBranchSdk.showShareSheet(
buo: buo,
linkProperties: lp,
Expand Down Expand Up @@ -539,7 +558,7 @@ class _HomePageState extends State<HomePage> {
.buffer
.asUint8List();
*/

initDeepLinkData();
FlutterBranchSdk.shareWithLPLinkMetadata(
buo: buo,
linkProperties: lp,
Expand Down

1 comment on commit 65acf63

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.