Skip to content

Commit

Permalink
Merge pull request #106 from RodrigoSMarques/dev
Browse files Browse the repository at this point in the history
Version 3.2.0
  • Loading branch information
RodrigoSMarques authored Jun 6, 2021
2 parents dab3b10 + fcc526e commit 1ce204c
Show file tree
Hide file tree
Showing 20 changed files with 221 additions and 38 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 3.2.0
* Updated Native `Android` and `iOS` SDKs:
**Android Native SDK Update 5.0.9 - [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases)
**iOS Native SDK Update 1.39.3 - [iOS Version History](https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/releases)
* [Added support do Facebook App Install Ads](https://help.branch.io/using-branch/docs/facebook-app-install-ads)
* Allow to enable and disable Branch Log
* Bug fix #100 NullPointerException when leaving the app
* Bug fix eventSink nulllpointer exception

## 3.1.0
* Updated Native `iOS` SDKs:
**iOS Native SDK Update 1.39.2 - [iOS Version History](https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/releases)
Expand Down
79 changes: 77 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -583,13 +583,88 @@ print(status);

See: [https://developer.apple.com/documentation/adsupport/asidentifiermanager/1614151-advertisingidentifier](https://developer.apple.com/documentation/adsupport/asidentifiermanager/1614151-advertisingidentifier)


### Enable Logging
Use the Branch test key instead of the live key.

Logging is enabled by default in debug mode and disabled in release mode.

To enable/disable logging update `INFO.PLIST` on `iOS` or `AndroidManifest.xml` on Android:

For `iOS` add to `INFO.PLIST`:

To disable:

```swift
<key>branch_enable_log</key>
<false/>
```

To enable:

```swift
<key>branch_enable_log</key>
<true/>
```

For `Android` add to `AndroidManifest.xml`:

To disable:

```java
<meta-data android:name="branch_enable_log"
android:value="false" />
```

To enable:

```java
<meta-data android:name="branch_enable_log"
android:value="true" />
```

### Facebook App Install Ads

Branch links can be used together with Facebook App Install Campaign ads, allowing you to track ad-driven installs on the Branch dashboard and deep link those new users directly to content the first time they open your app.

Follow the instructions on the link
<a href="https://help.branch.io/using-branch/docs/facebook-app-install-ads" target="_blank">https://help.branch.io/using-branch/docs/facebook-app-install-ads</a>.



To read Facebook App Install deep links update `INFO.PLIST` on `iOS` or `AndroidManifest.xml` on `Android` as in the example:

For `iOS` add to `INFO.PLIST`:

```swift
<key>branch_enable_facebook_ads</key>
<true/>
```

For `Android` add to `AndroidManifest.xml`:

```java
<meta-data android:name="branch_enable_facebook_ads"
android:value="true" />
```

Follow the instructions to install Facebook Android / iOS SDK:

`iOS`:

<a href="https://developers.facebook.com/docs/ios/use-cocoapods" target="_blank">https://developers.facebook.com/docs/ios/use-cocoapods</a>

`Android`:

<a href="https://developers.facebook.com/docs/android/getting-started" target="_blank">https://developers.facebook.com/docs/android/getting-started</a>



# Getting Started
See the `example` directory for a complete sample app using Branch SDK.

![Example app](https://github.com/RodrigoSMarques/flutter_branch_sdk/blob/dev/assets/example.png)

https://github.com/RodrigoSMarques/flutter_branch_sdk/blob/dev/assets/example.png

See example in Flutter Web: [https://flutter-branch-sdk.netlify.app/](https://flutter-branch-sdk.netlify.app/#/)

# Branch Universal Object best practices
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ android {
}

dependencies {
implementation 'io.branch.sdk.android:library:5.0.7'
implementation 'io.branch.sdk.android:library:5.0.9'
implementation 'com.google.firebase:firebase-appindexing:19.0.0'
implementation 'com.google.android.gms:play-services-ads-identifier:16+'
implementation 'androidx.browser:browser:1.3.0'
implementation 'androidx.lifecycle:lifecycle-runtime:2.2.0'
implementation 'androidx.lifecycle:lifecycle-runtime:2.3.1'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package br.com.rsmarques.flutter_branch_sdk;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

import io.flutter.BuildConfig;

public class ApplicationInfoHelper {
private static Context context;

ApplicationInfoHelper(Context context) {
this.context = context;
}

public static boolean getEnableLog() {
try {
final ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
if (ai.metaData != null) {
if (BuildConfig.DEBUG) {
return ai.metaData.getBoolean("branch_enable_log",
true);
} else {
return ai.metaData.getBoolean("branch_enable_log",
false);
}
} else {
return BuildConfig.DEBUG;
}
} catch (Exception e) {
LogUtils.debug("FlutterBranchSDK", "ApplicationInfoHelper error: " + e.getLocalizedMessage());
}
return false;
}

public static boolean getEnableFacebookAds() {
try {
final ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
if (ai.metaData != null) {
return ai.metaData.getBoolean("branch_enable_facebook_ads",
false);
} else {
return false;
}
} catch (Exception e) {
LogUtils.debug("FlutterBranchSDK", "ApplicationInfoHelper error: " + e.getLocalizedMessage());
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,4 @@ List<Object> jsonArrayToList(JSONArray array) throws JSONException {
}
return list;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
import android.util.Log;

import io.branch.referral.Branch;
import io.flutter.BuildConfig;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.plugin.common.PluginRegistry;

public class FlutterBranchSdkInit {
private static final String DEBUG_NAME = "FlutterBranchSDK";

public static void init(Context context) {
if (BuildConfig.DEBUG) {
LogUtils.debug(DEBUG_NAME, "Branch SDK in DebugMode");
ApplicationInfoHelper applicationInfoHelper = new ApplicationInfoHelper(context);

if (applicationInfoHelper.getEnableLog()) {
LogUtils.debug(DEBUG_NAME, "Branch SDK with log enable");
Branch.enableLogging();
} else {
Log.i(DEBUG_NAME, "Branch SDK with out log");
}

if (applicationInfoHelper.getEnableFacebookAds()) {
Branch.getAutoInstance(context).enableFacebookAppLinkCheck();
}

// Branch object initialization
Branch.getAutoInstance(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,9 @@ public void error(final String s, final String s1, final Object o) {
handler.post(new Runnable() {
@Override
public void run() {
eventSink.error(s, s1, o);
if (eventSink != null) {
eventSink.error(s, s1, o);
}
}
});
}
Expand All @@ -766,7 +768,9 @@ public void endOfStream() {
handler.post(new Runnable() {
@Override
public void run() {
eventSink.endOfStream();
if (eventSink != null) {
eventSink.endOfStream();
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.util.Log;


public class LogUtils {
public static void debug(final String tag, String message) {
if (BuildConfig.DEBUG) {
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 30

lintOptions {
disable 'InvalidPackage'
Expand All @@ -35,7 +35,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "br.com.rsmarques.flutter_branch_sdk_example"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
5 changes: 5 additions & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Flutter Branch SDK Example"
Expand Down Expand Up @@ -52,5 +53,9 @@
android:name="io.branch.sdk.BranchKey.test"
android:value="key_test_ipQTteg11ENANDeCzSXgqdgfuycWoXYH" />
<meta-data android:name="io.branch.sdk.TestMode" android:value="false" />
<meta-data android:name="branch_enable_log"
android:value="true" />
<meta-data android:name="branch_enable_facebook_ads"
android:value="false" />
</application>
</manifest>
2 changes: 1 addition & 1 deletion example/ios/Flutter/.last_build_id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2bdd54e69d3236f9bdfca342add5a2b8
c7efa40e8c2c02006bfd59baf861b387
21 changes: 15 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
PODS:
- Branch (1.39.2)
- Branch (1.39.3)
- FBSDKCoreKit (9.3.0):
- FBSDKCoreKit/Basics (= 9.3.0)
- FBSDKCoreKit/Core (= 9.3.0)
- FBSDKCoreKit/Basics (9.3.0)
- FBSDKCoreKit/Core (9.3.0):
- FBSDKCoreKit/Basics
- Flutter (1.0.0)
- flutter_branch_sdk (1.3.2):
- Branch (~> 1.39.2)
- flutter_branch_sdk (2.0.0):
- Branch (~> 1.39.3)
- Flutter

DEPENDENCIES:
- FBSDKCoreKit
- Flutter (from `Flutter`)
- flutter_branch_sdk (from `.symlinks/plugins/flutter_branch_sdk/ios`)

SPEC REPOS:
trunk:
- Branch
- FBSDKCoreKit

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

SPEC CHECKSUMS:
Branch: 6a281514287f99d707615ac62c2cca69e0213df0
Branch: 13df8e1a6985745a03389146df1eeda723645a97
FBSDKCoreKit: 0d1ae58388a458b8222f72025804cdc84eb5d0c3
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
flutter_branch_sdk: 7a2a9258f5e3d5234facf38e278082e187b29b35
flutter_branch_sdk: 3d609ce62f51d975d477bce421339e0e59b38c92

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
PODFILE CHECKSUM: ce2034713f2733d5fb10f2ff94b1422d1b413e42

COCOAPODS: 1.10.1
2 changes: 2 additions & 0 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,13 @@
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Branch/Branch.framework",
"${BUILT_PRODUCTS_DIR}/FBSDKCoreKit/FBSDKCoreKit.framework",
"${BUILT_PRODUCTS_DIR}/flutter_branch_sdk/flutter_branch_sdk.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Branch.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKCoreKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_branch_sdk.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down
4 changes: 4 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,9 @@
<string>key_test_ipQTteg11ENANDeCzSXgqdgfuycWoXYH</string>
<key>NSUserTrackingUsageDescription</key>
<string>App would like to access IDFA for tracking purpose</string>
<key>branch_enable_log</key>
<true/>
<key>branch_enable_facebook_ads</key>
<false/>
</dict>
</plist>
8 changes: 4 additions & 4 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.6.1"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -68,7 +68,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.1.0"
version: "3.2.0"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -125,7 +125,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -160,7 +160,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
version: "0.3.0"
typed_data:
dependency: transitive
description:
Expand Down
Loading

0 comments on commit 1ce204c

Please sign in to comment.