diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a27788fb..9a8a0105 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,6 +4,8 @@ on: push: branches: - "master" + - "dev" + - "bugfix" paths-ignore: - "**/README.md" - "docs/**" @@ -11,6 +13,7 @@ on: branches: - "master" - "dev" + - "bugfix" jobs: check-lint-flutter: diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d9c3651..5568aef5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 7.0.2 +### Issues + +* Fix issue #261 / #266 / #268: Calling startActivity() from outside of an Activity +* Fix issue #264: Android (PlayStore) : Branch SDK Params empty on background state +* Fix issue #265: New release 7.0.0+ not getting a deeplink data on first launch, when app is on resume +* Fix issue #270: Indicate when error is thrown in init + +### Native SDK Updates + +* Updated included Android SDK to 5.8.0 - [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases) + ## 7.0.1 * Fix issue #255: `Attempt to invoke virtual method 'int android.content.Intent.getFlags()' on a null object reference` when using FlutterFragmentActivity * Fix issue #256: `A problem occurred configuring project ':flutter_branch_sdk'.` - Add compatibility with AGP 8 (Android Gradle Plugin) diff --git a/README.md b/README.md index 8308995c..00d17c95 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![Branch](https://github.com/RodrigoSMarques/flutter_branch_sdk/blob/master/assets/branch.png?raw=true)](https://branch.io) +[![Plugin code analysis](https://github.com/RodrigoSMarques/flutter_branch_sdk/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/RodrigoSMarques/flutter_branch_sdk/actions/workflows/ci.yaml) + This is a Flutter plugin that implemented [Branch SDK](https://branch.io). Branch.io helps mobile apps grow with deep links that power referral systems, sharing links and invites with full attribution and analytics. diff --git a/android/build.gradle b/android/build.gradle index bf39c50c..02f28c11 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -50,7 +50,7 @@ android { } dependencies { - implementation 'io.branch.sdk.android:library:5.7.+' + implementation 'io.branch.sdk.android:library:5.8.+' implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' implementation 'androidx.browser:browser:1.5.0' implementation 'androidx.lifecycle:lifecycle-runtime:2.5.1' diff --git a/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/ApplicationInfoHelper.java b/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/ApplicationInfoHelper.java deleted file mode 100644 index ddcb0747..00000000 --- a/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/ApplicationInfoHelper.java +++ /dev/null @@ -1,35 +0,0 @@ -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; - } -} diff --git a/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkInit.java b/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkInit.java deleted file mode 100644 index 56562021..00000000 --- a/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkInit.java +++ /dev/null @@ -1,26 +0,0 @@ -package br.com.rsmarques.flutter_branch_sdk; - -import android.content.Context; -import android.util.Log; - -import io.branch.referral.Branch; - -public class FlutterBranchSdkInit { - private static final String DEBUG_NAME = "FlutterBranchSDK"; - private static final String PLUGIN_NAME = "Flutter"; - private static final String PLUGIN_VERSION = "7.0.0"; - - public static void init(Context context) { - 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"); - } - - // Branch object initialization - Branch.getAutoInstance(context); - } -} 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 01203df6..e98d98c3 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 @@ -23,6 +23,7 @@ import io.branch.indexing.BranchUniversalObject; import io.branch.referral.Branch; import io.branch.referral.BranchError; +import io.branch.referral.BuildConfig; import io.branch.referral.QRCode.BranchQRCode; import io.branch.referral.ServerRequestGetLATD; import io.branch.referral.util.BranchEvent; @@ -44,22 +45,18 @@ public class FlutterBranchSdkPlugin implements FlutterPlugin, MethodCallHandler, StreamHandler, NewIntentListener, ActivityAware, Application.ActivityLifecycleCallbacks { - private static final String DEBUG_NAME = "FlutterBranchSDK"; private static final String MESSAGE_CHANNEL = "flutter_branch_sdk/message"; private static final String EVENT_CHANNEL = "flutter_branch_sdk/event"; private static final String PLUGIN_NAME = "Flutter"; - private Activity activity; private Context context; private ActivityPluginBinding activityPluginBinding; - private EventSink eventSink = null; private Map sessionParams = null; private BranchError initialError = null; private final FlutterBranchSdkHelper branchSdkHelper = new FlutterBranchSdkHelper(); private boolean isInitialized = false; - private final JSONObject requestMetadata = new JSONObject(); private final JSONObject facebookParameters = new JSONObject(); private final JSONObject snapParameters = new JSONObject(); @@ -72,21 +69,20 @@ public class FlutterBranchSdkPlugin implements FlutterPlugin, MethodCallHandler, * Plugin registry * -------------------------------------------------------------------------------------------- **/ - @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { - LogUtils.debug(DEBUG_NAME, "onAttachedToEngine call"); + LogUtils.debug(DEBUG_NAME, "triggered onAttachedToEngine"); setupChannels(binding.getBinaryMessenger(), binding.getApplicationContext()); } @Override public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { - LogUtils.debug(DEBUG_NAME, "onDetachedFromEngine call"); + LogUtils.debug(DEBUG_NAME, "triggered onDetachedFromEngine"); teardownChannels(); } private void setupChannels(BinaryMessenger messenger, Context context) { - LogUtils.debug(DEBUG_NAME, "setupChannels call"); + LogUtils.debug(DEBUG_NAME, "triggered setupChannels"); this.context = context; MethodChannel methodChannel = new MethodChannel(messenger, MESSAGE_CHANNEL); @@ -97,14 +93,14 @@ private void setupChannels(BinaryMessenger messenger, Context context) { } private void setActivity(Activity activity) { - LogUtils.debug(DEBUG_NAME, "setActivity call"); + LogUtils.debug(DEBUG_NAME, "triggered setActivity"); this.activity = activity; initialIntent = activity.getIntent(); activity.getApplication().registerActivityLifecycleCallbacks(this); } private void teardownChannels() { - LogUtils.debug(DEBUG_NAME, "teardownChannels call"); + LogUtils.debug(DEBUG_NAME, "triggered teardownChannels"); this.activityPluginBinding = null; this.activity = null; this.context = null; @@ -117,7 +113,7 @@ private void teardownChannels() { **/ @Override public void onAttachedToActivity(ActivityPluginBinding activityPluginBinding) { - LogUtils.debug(DEBUG_NAME, "onAttachedToActivity call"); + LogUtils.debug(DEBUG_NAME, "triggered onAttachedToActivity"); this.activityPluginBinding = activityPluginBinding; setActivity(activityPluginBinding.getActivity()); activityPluginBinding.addOnNewIntentListener(this); @@ -125,20 +121,20 @@ public void onAttachedToActivity(ActivityPluginBinding activityPluginBinding) { @Override public void onDetachedFromActivity() { - LogUtils.debug(DEBUG_NAME, "onDetachedFromActivity call"); + LogUtils.debug(DEBUG_NAME, "triggered onDetachedFromActivity"); activityPluginBinding.removeOnNewIntentListener(this); this.activity = null; } @Override public void onDetachedFromActivityForConfigChanges() { - LogUtils.debug(DEBUG_NAME, "onDetachedFromActivityForConfigChanges call"); + LogUtils.debug(DEBUG_NAME, "triggered onDetachedFromActivityForConfigChanges"); onDetachedFromActivity(); } @Override public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding activityPluginBinding) { - LogUtils.debug(DEBUG_NAME, "onReattachedToActivityForConfigChanges call"); + LogUtils.debug(DEBUG_NAME, "triggered onReattachedToActivityForConfigChanges"); onAttachedToActivity(activityPluginBinding); } @@ -149,7 +145,7 @@ public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBindin **/ @Override public void onListen(Object o, EventChannel.EventSink eventSink) { - LogUtils.debug(DEBUG_NAME, "onListen call"); + LogUtils.debug(DEBUG_NAME, "triggered onListen"); this.eventSink = new MainThreadEventSink(eventSink); if (sessionParams != null) { eventSink.success(sessionParams); @@ -164,7 +160,7 @@ public void onListen(Object o, EventChannel.EventSink eventSink) { @Override public void onCancel(Object o) { - LogUtils.debug(DEBUG_NAME, "onCancel call"); + LogUtils.debug(DEBUG_NAME, "triggered onCancel"); this.eventSink = new MainThreadEventSink(null); initialError = null; sessionParams = null; @@ -176,38 +172,39 @@ public void onCancel(Object o) { * -------------------------------------------------------------------------------------------- **/ @Override - public void onActivityCreated(Activity activity, Bundle bundle) { + public void onActivityCreated(@NonNull Activity activity, Bundle bundle) { } @Override - public void onActivityStarted(Activity activity) { - LogUtils.debug(DEBUG_NAME, "onActivityStarted call"); + public void onActivityStarted(@NonNull Activity activity) { + LogUtils.debug(DEBUG_NAME, "triggered onActivityStarted"); if (!isInitialized) { return; } + LogUtils.debug(DEBUG_NAME, "triggered SessionBuilder init"); Branch.sessionBuilder(activity).withCallback(branchReferralInitListener).withData(activity.getIntent().getData()).init(); } @Override - public void onActivityResumed(Activity activity) { + public void onActivityResumed(@NonNull Activity activity) { } @Override - public void onActivityPaused(Activity activity) { + public void onActivityPaused(@NonNull Activity activity) { } @Override - public void onActivityStopped(Activity activity) { - LogUtils.debug(DEBUG_NAME, "onActivityStopped call"); + public void onActivityStopped(@NonNull Activity activity) { + LogUtils.debug(DEBUG_NAME, "triggered onActivityStopped"); } @Override - public void onActivitySaveInstanceState(Activity activity, Bundle bundle) { + public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle bundle) { } @Override - public void onActivityDestroyed(Activity activity) { - LogUtils.debug(DEBUG_NAME, "onActivityDestroyed call"); + public void onActivityDestroyed(@NonNull Activity activity) { + LogUtils.debug(DEBUG_NAME, "triggered onActivityDestroyed"); if (this.activity == activity) { activity.getApplication().unregisterActivityLifecycleCallbacks(this); } @@ -219,23 +216,19 @@ public void onActivityDestroyed(Activity activity) { * -------------------------------------------------------------------------------------------- **/ @Override - public boolean onNewIntent(Intent intent) { - LogUtils.debug(DEBUG_NAME, "onNewIntent call"); - + public boolean onNewIntent(@NonNull Intent intent) { + LogUtils.debug(DEBUG_NAME, "triggered onNewIntent"); if (!isInitialized) { return false; } - - if (this.activity == null || intent == null) { + if (this.activity == null) { return false; } - - Intent newIntent = intent; - if (!intent.hasExtra("branch_force_new_session")) { - newIntent.putExtra("branch_force_new_session", true); + this.activity.setIntent(intent); + if (intent.hasExtra("branch_force_new_session") && intent.getBooleanExtra("branch_force_new_session",false)) { + Branch.sessionBuilder(this.activity).withCallback(branchReferralInitListener).reInit(); + LogUtils.debug(DEBUG_NAME, "triggered SessionBuilder reInit"); } - this.activity.setIntent(newIntent); - Branch.sessionBuilder(this.activity).withCallback(branchReferralInitListener).reInit(); return true; } @@ -348,7 +341,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result rawResult) { Branch.BranchReferralInitListener() { @Override public void onInitFinished(JSONObject params, BranchError error) { - LogUtils.debug(DEBUG_NAME, "onInitFinished - call"); + LogUtils.debug(DEBUG_NAME, "triggered onInitFinished"); if (error == null) { LogUtils.debug(DEBUG_NAME, "BranchReferralInitListener - params: " + params.toString()); try { @@ -362,10 +355,6 @@ public void onInitFinished(JSONObject params, BranchError error) { sessionParams = null; } } else { - //if (error.getErrorCode() == BranchError.ERR_BRANCH_ALREADY_INITIALIZED || error.getErrorCode() == BranchError.ERR_IMPROPER_REINITIALIZATION) { - // LogUtils.debug(DEBUG_NAME, "BranchReferralInitListener - error: ERR_BRANCH_ALREADY_INITIALIZED"); - // return; - //} LogUtils.debug(DEBUG_NAME, "BranchReferralInitListener - error: " + error); if (eventSink != null) { eventSink.error(String.valueOf(error.getErrorCode()), error.getMessage(), null); @@ -378,7 +367,7 @@ public void onInitFinished(JSONObject params, BranchError error) { }; private void setupBranch(MethodCall call, final Result result) { - LogUtils.debug(DEBUG_NAME, "setupBranch call"); + LogUtils.debug(DEBUG_NAME, "triggered setupBranch"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -396,7 +385,6 @@ private void setupBranch(MethodCall call, final Result result) { } Branch.registerPlugin(PLUGIN_NAME, (String) argsMap.get("version")); Branch.getAutoInstance(this.context); - isInitialized = true; if (requestMetadata.length() > 0) { Iterator keys = requestMetadata.keys(); @@ -444,7 +432,16 @@ private void setupBranch(MethodCall call, final Result result) { if ((Boolean) argsMap.get("disableTracking")) { Branch.getInstance().disableTracking(true); } + isInitialized = true; + if (initialIntent == null) { + initialIntent = new Intent(this.context, this.activity.getClass()); + initialIntent.setAction(Intent.ACTION_MAIN); + initialIntent.addCategory(Intent.CATEGORY_LAUNCHER); + } + initialIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + initialIntent.putExtra("branch_force_new_session", true); this.context.startActivity(initialIntent); + initialIntent = null; result.success(Boolean.TRUE); } @@ -531,7 +528,7 @@ public boolean onChannelSelected(String channelName, BranchUniversalObject buo, } private void registerView(MethodCall call) { - LogUtils.debug(DEBUG_NAME, "registerView call"); + LogUtils.debug(DEBUG_NAME, "triggered registerView"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -546,7 +543,7 @@ public void run() { } private void listOnSearch(MethodCall call, Result result) { - LogUtils.debug(DEBUG_NAME, "listOnSearch call"); + LogUtils.debug(DEBUG_NAME, "triggered listOnSearch"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -562,7 +559,7 @@ private void listOnSearch(MethodCall call, Result result) { } private void removeFromSearch(MethodCall call, Result result) { - LogUtils.debug(DEBUG_NAME, "removeFromSearch call"); + LogUtils.debug(DEBUG_NAME, "triggered removeFromSearch"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -578,7 +575,7 @@ private void removeFromSearch(MethodCall call, Result result) { } private void trackContent(MethodCall call) { - LogUtils.debug(DEBUG_NAME, "trackContent call"); + LogUtils.debug(DEBUG_NAME, "triggered trackContent"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -597,7 +594,7 @@ public void run() { } private void trackContentWithoutBuo(MethodCall call) { - LogUtils.debug(DEBUG_NAME, "trackContentWithoutBuo call"); + LogUtils.debug(DEBUG_NAME, "triggered trackContentWithoutBuo"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -612,7 +609,7 @@ public void run() { } private void setIdentity(MethodCall call) { - LogUtils.debug(DEBUG_NAME, "setIdentity call"); + LogUtils.debug(DEBUG_NAME, "triggered setIdentity"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -626,7 +623,7 @@ public void run() { } private void setRequestMetadata(MethodCall call) { - LogUtils.debug(DEBUG_NAME, "setRequestMetadata call"); + LogUtils.debug(DEBUG_NAME, "triggered setRequestMetadata"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -652,7 +649,7 @@ public void run() { } private void logout() { - LogUtils.debug(DEBUG_NAME, "logout call"); + LogUtils.debug(DEBUG_NAME, "triggered logout"); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { @@ -662,7 +659,7 @@ public void run() { } private void getLatestReferringParams(Result result) { - LogUtils.debug(DEBUG_NAME, "getLatestReferringParams call"); + LogUtils.debug(DEBUG_NAME, "triggered getLatestReferringParams"); JSONObject sessionParams = Branch.getInstance().getLatestReferringParams(); try { result.success(branchSdkHelper.paramsToMap(sessionParams)); @@ -673,7 +670,7 @@ private void getLatestReferringParams(Result result) { } private void getFirstReferringParams(Result result) { - LogUtils.debug(DEBUG_NAME, "getFirstReferringParams call"); + LogUtils.debug(DEBUG_NAME, "triggered getFirstReferringParams"); JSONObject sessionParams = Branch.getInstance().getFirstReferringParams(); try { result.success(branchSdkHelper.paramsToMap(sessionParams)); @@ -684,7 +681,7 @@ private void getFirstReferringParams(Result result) { } private void setTrackingDisabled(MethodCall call) { - LogUtils.debug(DEBUG_NAME, "setTrackingDisabled call"); + LogUtils.debug(DEBUG_NAME, "triggered setTrackingDisabled"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -698,12 +695,12 @@ public void run() { } private void isUserIdentified(Result result) { - LogUtils.debug(DEBUG_NAME, "isUserIdentified call"); + LogUtils.debug(DEBUG_NAME, "triggered isUserIdentified"); result.success(Branch.getInstance().isUserIdentified()); } private void setConnectTimeout(final MethodCall call) { - LogUtils.debug(DEBUG_NAME, "setConnectTimeout call"); + LogUtils.debug(DEBUG_NAME, "triggered setConnectTimeout"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -717,7 +714,7 @@ public void run() { } private void setTimeout(final MethodCall call) { - LogUtils.debug(DEBUG_NAME, "setConnectTimeout call"); + LogUtils.debug(DEBUG_NAME, "triggered setConnectTimeout"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -731,7 +728,7 @@ public void run() { } private void setRetryCount(final MethodCall call) { - LogUtils.debug(DEBUG_NAME, "setRetryCount call"); + LogUtils.debug(DEBUG_NAME, "triggered setRetryCount"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -745,7 +742,7 @@ public void run() { } private void setRetryInterval(final MethodCall call) { - LogUtils.debug(DEBUG_NAME, "setRetryInterval call"); + LogUtils.debug(DEBUG_NAME, "triggered setRetryInterval"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -759,7 +756,7 @@ public void run() { } private void getLastAttributedTouchData(final MethodCall call, final Result result) { - LogUtils.debug(DEBUG_NAME, "getLastAttributedTouchData call"); + LogUtils.debug(DEBUG_NAME, "triggered getLastAttributedTouchData"); final Map response = new HashMap<>(); if (call.hasArgument("attributionWindow")) { final int attributionWindow = call.argument("attributionWindow"); @@ -811,7 +808,7 @@ public void onDataFetched(JSONObject jsonObject, BranchError error) { } private void getQRCode(final MethodCall call, final Result result) { - LogUtils.debug(DEBUG_NAME, "getQRCodeAsData call"); + LogUtils.debug(DEBUG_NAME, "triggered getQRCodeAsData"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -847,7 +844,7 @@ public void onFailure(Exception error) { } private void handleDeepLink(final MethodCall call) { - LogUtils.debug(DEBUG_NAME, "handleDeepLink call"); + LogUtils.debug(DEBUG_NAME, "triggered handleDeepLink"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -859,7 +856,7 @@ private void handleDeepLink(final MethodCall call) { } private void addFacebookPartnerParameter(MethodCall call) { - LogUtils.debug(DEBUG_NAME, "addFacebookPartnerParameter call"); + LogUtils.debug(DEBUG_NAME, "triggered addFacebookPartnerParameter"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -885,7 +882,7 @@ public void run() { } private void clearPartnerParameters() { - LogUtils.debug(DEBUG_NAME, "clearPartnerParameters call"); + LogUtils.debug(DEBUG_NAME, "triggered clearPartnerParameters"); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { @@ -895,7 +892,7 @@ public void run() { } private void setPreinstallCampaign(MethodCall call) { - LogUtils.debug(DEBUG_NAME, "setPreinstallCampaign call"); + LogUtils.debug(DEBUG_NAME, "triggered setPreinstallCampaign"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -913,7 +910,7 @@ public void run() { } private void setPreinstallPartner(MethodCall call) { - LogUtils.debug(DEBUG_NAME, "setPreinstallPartner call"); + LogUtils.debug(DEBUG_NAME, "triggered setPreinstallPartner"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } @@ -931,7 +928,7 @@ public void run() { } private void addSnapPartnerParameter(MethodCall call) { - LogUtils.debug(DEBUG_NAME, "addSnapPartnerParameter call"); + LogUtils.debug(DEBUG_NAME, "triggered addSnapPartnerParameter"); if (!(call.arguments instanceof Map)) { throw new IllegalArgumentException("Map argument expected"); } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 8e908fb6..bd55e087 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,7 +1,7 @@ PODS: - BranchSDK (3.0.0) - Flutter (1.0.0) - - flutter_branch_sdk (7.0.0-beta.2): + - flutter_branch_sdk (7.0.2): - BranchSDK (~> 3.0.0) - Flutter @@ -22,8 +22,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: BranchSDK: e9c0332b2655cf0357d93db479d07152b059e434 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - flutter_branch_sdk: d44ccbe957868d4ff816258a436c23959f6e4cda + flutter_branch_sdk: 074b3a7e9c8214c3f19c1b72840c114abb641b06 PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048 -COCOAPODS: 1.13.0 \ No newline at end of file +COCOAPODS: 1.13.0 diff --git a/example/lib/custom_button.dart b/example/lib/custom_button.dart index cee297ac..d7b42be6 100644 --- a/example/lib/custom_button.dart +++ b/example/lib/custom_button.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; class CustomButton extends StatelessWidget { - const CustomButton({Key? key, required this.onPressed, required this.child}) - : super(key: key); + const CustomButton({super.key, required this.onPressed, required this.child}); final GestureTapCallback onPressed; final Widget child; diff --git a/example/lib/main.dart b/example/lib/main.dart index 4437fc24..93945277 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -32,7 +32,7 @@ void main() async { } class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp({super.key}); @override Widget build(BuildContext context) { @@ -49,7 +49,7 @@ class MyApp extends StatelessWidget { } class HomePage extends StatefulWidget { - const HomePage({Key? key}) : super(key: key); + const HomePage({super.key}); @override State createState() => _HomePageState(); @@ -60,10 +60,10 @@ class _HomePageState extends State { GlobalKey(); BranchContentMetaData metadata = BranchContentMetaData(); - BranchUniversalObject? buo; BranchLinkProperties lp = BranchLinkProperties(); - BranchEvent? eventStandard; - BranchEvent? eventCustom; + late BranchUniversalObject buo; + late BranchEvent eventStandard; + late BranchEvent eventCustom; StreamSubscription? streamSubscription; StreamController controllerData = StreamController(); @@ -284,18 +284,18 @@ class _HomePageState extends State { } void registerView() { - FlutterBranchSdk.registerView(buo: buo!); + FlutterBranchSdk.registerView(buo: buo); showSnackBar(message: 'Event Registered'); } void trackContent() { - FlutterBranchSdk.trackContent(buo: [buo!], branchEvent: eventStandard!); + FlutterBranchSdk.trackContent(buo: [buo], branchEvent: eventStandard); - FlutterBranchSdk.trackContent(buo: [buo!], branchEvent: eventCustom!); + FlutterBranchSdk.trackContent(buo: [buo], branchEvent: eventCustom); - //FlutterBranchSdk.trackContentWithoutBuo(branchEvent: eventStandard!); + FlutterBranchSdk.trackContentWithoutBuo(branchEvent: eventStandard); - //FlutterBranchSdk.trackContentWithoutBuo(branchEvent: eventCustom!); + FlutterBranchSdk.trackContentWithoutBuo(branchEvent: eventCustom); showSnackBar(message: 'Tracked content'); } @@ -334,11 +334,10 @@ class _HomePageState extends State { return; } //Buo without Link Properties - bool success = await FlutterBranchSdk.listOnSearch(buo: buo!); + bool success = await FlutterBranchSdk.listOnSearch(buo: buo); //Buo with Link Properties - success = - await FlutterBranchSdk.listOnSearch(buo: buo!, linkProperties: lp); + success = await FlutterBranchSdk.listOnSearch(buo: buo, linkProperties: lp); if (success) { showSnackBar(message: 'Listed on Search'); @@ -350,9 +349,9 @@ class _HomePageState extends State { showSnackBar(message: 'removeFromSearch() not available in Flutter Web'); return; } - bool success = await FlutterBranchSdk.removeFromSearch(buo: buo!); + bool success = await FlutterBranchSdk.removeFromSearch(buo: buo); success = - await FlutterBranchSdk.removeFromSearch(buo: buo!, linkProperties: lp); + await FlutterBranchSdk.removeFromSearch(buo: buo, linkProperties: lp); if (success) { showSnackBar(message: 'Removed from Search'); } @@ -360,7 +359,7 @@ class _HomePageState extends State { void generateLink(BuildContext context) async { BranchResponse response = - await FlutterBranchSdk.getShortUrl(buo: buo!, linkProperties: lp); + await FlutterBranchSdk.getShortUrl(buo: buo, linkProperties: lp); if (response.success) { if (context.mounted) { showGeneratedLink(context, response.result); @@ -394,7 +393,7 @@ class _HomePageState extends State { */ BranchResponse responseQrCodeImage = await FlutterBranchSdk.getQRCodeAsImage( - buo: buo!, + buo: buo, linkProperties: lp, qrCode: BranchQrCode( primaryColor: Colors.black, @@ -507,7 +506,7 @@ class _HomePageState extends State { void shareLink() async { BranchResponse response = await FlutterBranchSdk.showShareSheet( - buo: buo!, + buo: buo, linkProperties: lp, messageText: 'My Share text', androidMessageTitle: 'My Message Title', @@ -542,7 +541,7 @@ class _HomePageState extends State { */ FlutterBranchSdk.shareWithLPLinkMetadata( - buo: buo!, + buo: buo, linkProperties: lp, title: "Share With LPLinkMetadata", icon: iconData); diff --git a/example/pubspec.lock b/example/pubspec.lock index 9ed664dd..889c3f44 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" cupertino_icons: dependency: "direct main" description: @@ -68,15 +68,15 @@ packages: path: ".." relative: true source: path - version: "7.0.1" + version: "7.0.2" flutter_lints: dependency: "direct dev" description: name: flutter_lints - sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7 url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "3.0.1" flutter_test: dependency: "direct dev" description: flutter @@ -99,10 +99,10 @@ packages: dependency: transitive description: name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "3.0.0" matcher: dependency: transitive description: @@ -123,10 +123,10 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" path: dependency: transitive description: @@ -139,10 +139,10 @@ packages: dependency: transitive description: name: plugin_platform_interface - sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 url: "https://pub.dev" source: hosted - version: "2.1.6" + version: "2.1.7" sky_engine: dependency: transitive description: flutter @@ -160,18 +160,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -192,10 +192,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" vector_math: dependency: transitive description: @@ -208,10 +208,10 @@ packages: dependency: transitive description: name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "0.3.0" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" + dart: ">=3.2.0-194.0.dev <4.0.0" flutter: ">=3.3.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 1c7571e4..07dc5644 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -39,7 +39,7 @@ dev_dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^2.0.0 + flutter_lints: ^3.0.1 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/ios/Classes/SwiftFlutterBranchSdkPlugin.swift b/ios/Classes/SwiftFlutterBranchSdkPlugin.swift index 5783d2de..7fcbaaf0 100644 --- a/ios/Classes/SwiftFlutterBranchSdkPlugin.swift +++ b/ios/Classes/SwiftFlutterBranchSdkPlugin.swift @@ -238,9 +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) } @@ -296,7 +300,7 @@ public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStream return } self.eventSink!(FlutterError(code: String(err.code), - message: err.localizedDescription, + message: "Branch InitSession error: \(err.localizedDescription)", details: nil)) } } diff --git a/lib/src/flutter_branch_sdk_method_channel.dart b/lib/src/flutter_branch_sdk_method_channel.dart index ba0e720c..142a28da 100644 --- a/lib/src/flutter_branch_sdk_method_channel.dart +++ b/lib/src/flutter_branch_sdk_method_channel.dart @@ -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.1"; + static const PLUGIN_VERSION = "7.0.2"; static const MESSAGE_CHANNEL = 'flutter_branch_sdk/message'; static const EVENT_CHANNEL = 'flutter_branch_sdk/event'; diff --git a/pubspec.lock b/pubspec.lock index f0b6e168..feb6552b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" fake_async: dependency: transitive description: @@ -58,10 +58,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7 url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "3.0.1" flutter_test: dependency: "direct dev" description: flutter @@ -84,10 +84,10 @@ packages: dependency: transitive description: name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "3.0.0" matcher: dependency: transitive description: @@ -108,10 +108,10 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" path: dependency: transitive description: @@ -124,10 +124,10 @@ packages: dependency: "direct main" description: name: plugin_platform_interface - sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 url: "https://pub.dev" source: hosted - version: "2.1.6" + version: "2.1.7" sky_engine: dependency: transitive description: flutter @@ -145,18 +145,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -177,10 +177,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" vector_math: dependency: transitive description: @@ -193,10 +193,10 @@ packages: dependency: transitive description: name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "0.3.0" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" + dart: ">=3.2.0-194.0.dev <4.0.0" flutter: ">=3.3.0" diff --git a/pubspec.yaml b/pubspec.yaml index 1e3835c3..a4558692 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.1 +version: 7.0.2 homepage: https://github.com/RodrigoSMarques/flutter_branch_sdk environment: @@ -12,13 +12,13 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - plugin_platform_interface: ^2.1.6 + plugin_platform_interface: ^2.1.7 js: ^0.6.7 dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.3 + flutter_lints: ^3.0.1 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec