Skip to content

Commit

Permalink
Merge pull request #618 from BranchMetrics/staging
Browse files Browse the repository at this point in the history
Release 4.0.1
  • Loading branch information
bklastaitis-branch authored Feb 4, 2020
2 parents 354d023 + a565c9d commit c568eaa
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 162 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ package-lock.json
npm-debug.log*
yarn-error.log*
.vscode
.idea
src/android/.idea
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ _Questions? [Contact us](https://support.branch.io/support/tickets/new)_
* [Compiling: Updating the Branch SDK](#compiling-updating-the-branch-sdk)
* [Compiling: Incompatible Plugins](#compiling-incompatible-plugins)
* [Compiling: Errors](#compiling-errors)
* [Compiling: Capacitor](#compiling-capacitor)
* [AppStore: iOS](#appstore-ios)

## Getting Started

Expand Down Expand Up @@ -727,7 +729,6 @@ _Questions? [Contact us](https://support.branch.io/support/tickets/new)_
<link-domain value="bnc.lt" /> <!-- optional previous link domain -->
<ios-team-release value="PW4Q8885U7" /> <!-- required if iOS app -->
<ios-team-debug value="FG35JLLMXX" /> <!-- optional -->
<android-prefix value="/WSuf" /> <!-- optional (for bnc.lt link domains) -->
<android-testmode value="true" /> <!-- optional (simulate installs) -->
</branch-config>
```
Expand Down Expand Up @@ -1348,3 +1349,61 @@ _Questions? [Contact us](https://support.branch.io/support/tickets/new)_
```
* Add `<preference name="android-minSdkVersion" value="16" />` to your `config.xml`
* error
```sh
Branch.h not found
```
If that is the ONLY error you see, this can be fixed by upgrading dependencies.
Ensure you are using version 4.0.1 of this plugin or higher and have updated your Xcode, Cordova, and other dependencies (listed below) to the latest versions. This error arose due to an inability in CocoaPods and cordova-ios to resolve dependencies that was later fixed.
Sometimes this error occurs when a build error occurs in the Pod project; since Branch is usually the first pod alphabetically, it'll show up as the error when attempting to build the main project (since the Pod didn't get built), even though the real error is elsewhere. Make sure to read your build log to find the original error that prevented building the Pod project.
* error: ios build fails with Pods and CONFIGURATION_BUILD_DIR configured
Command-line builds result in the above error. Please see the section below [Compiling: Capacitor](#compiling-capacitor) for the full list of up-to-date dependencies needed for CLI builds to work.
* #### Compiling: Capacitor
* ##### Version 4.0.1 of this plugin works with Ionic 4 + Cordova and Ionic 4 + Capacitor, with the following caveats:
* We strongly recommend Node >= 10.15. Node 8 might work, but it is not tested.
* For BOTH Cordova and Capacitor, you must use Xcode >= 11.1, CocoaPods >= 1.8.4, Cordova >= 9.0.0, Ionic-CLI >= 5.1, cordova-ios >= 5.1.0
* Every single one of these dependencies has fixes that allow the command line build, and the pod dependency resolution to work correctly
* You MUST use @capacitor/ios >= 1.4.0. Versions prior to that version did not federate the OpenURL notifications to other plugins, including Branch.
* `use_frameworks` has been removed from this plugin and will now be statically built. If the other podfile uses `use_frameworks` that is fine but this plugin no longer flags itself as dynamic.
* When using Capacitor, you must add the following entries yourself to `ios/App/App/Info.plist`:
```sh
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.getcapacitor.capacitor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>capacitor</string>
</array>
</dict>
<dict>
<key>CFBundleURLName</key>
<string>branch-cordova-sdk</string>
<key>CFBundleURLSchemes</key>
<array>
<string>[YOUR URL SCHEME HERE]</string>
</array>
</dict>
</array>
<key>branch_key</key>
<string>[YOUR BRANCH LIVE KEY]</string>
<key>branch_app_domain</key>
<string>[YOUR DOMAIN].app.link</string>
```
* When using Capacitor, you must add your Associated Domains entitlements via the Xcode entitlement editor yourself
* This MUST be done using Xcode - this is part of Capacitor's philosophy whereby you are in control of every config file change
* Open the "Signing & Entitlements" tab in Xcode, add the Associated Domains entitlement, and add the urls found on your Branch dashboard.

* #### AppStore: iOS

* #### App rejected because it uses push notification features but does not declare the aps-environment key
When branch-cordova-sdk moved to use CocoaPods, a change was introduced in Cordova 9 where the separate entitlement files were no longer flattened together. This issue has been fixed in version 4.0.1 of this plugin.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "branch-cordova-sdk",
"description": "Branch Metrics Cordova SDK",
"main": "src/index.js",
"version": "4.0.0",
"version": "4.1.0",
"homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking",
"repository": {
"type": "git",
Expand All @@ -17,7 +17,7 @@
],
"license": "MIT",
"engines": [
{
{
"name": "cordova",
"version": ">=9.0.0"
}
Expand Down
10 changes: 5 additions & 5 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="branch-cordova-sdk"
version="4.0.0">
version="4.1.0">

<!-- Description -->
<name>branch-cordova-sdk</name>
Expand All @@ -36,7 +36,7 @@ SOFTWARE.

<!-- Dependencies -->
<engines>
<engine name="cordova" version=">=3.5.0" />
<engine name="cordova" version=">=9.0.0" />
</engines>

<!-- Hooks -->
Expand All @@ -62,7 +62,7 @@ SOFTWARE.
<!-- Manifest configuration is done via a js script. We should move it to this config in the future. -->

<source-file src="src/android/io/branch/BranchSDK.java" target-dir="src/io/branch" />
<framework src="io.branch.sdk.android:library:4.1.1"/>
<framework src="io.branch.sdk.android:library:4.3.2"/>
</platform>

<!-- iOS -->
Expand All @@ -85,8 +85,8 @@ SOFTWARE.
<config>
<source url="https://github.com/CocoaPods/Specs.git"/>
</config>
<pods use-frameworks="true">
<pod name="Branch" spec="~> 0.29.0" />
<pods>
<pod name="Branch" spec="~> 0.31.3" />
</pods>
</podspec>
</platform>
Expand Down
43 changes: 26 additions & 17 deletions src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import io.branch.indexing.BranchUniversalObject;
import io.branch.referral.Branch;
import io.branch.referral.BranchUtil;
import io.branch.referral.PrefHelper;
import io.branch.referral.BranchError;
import io.branch.referral.BranchViewHandler;
import io.branch.referral.SharingHelper;
Expand All @@ -31,8 +33,9 @@
import io.branch.referral.util.ProductCategory;
import io.branch.referral.util.ShareSheetStyle;

import io.branch.referral.util.BranchCrossPlatformId;
import io.branch.referral.util.BranchLastAttributedTouchData;
import io.branch.referral.ServerRequestGetLATD.BranchLastAttributedTouchDataListener;
import io.branch.referral.ServerRequestGetCPID.BranchCrossPlatformIdListener;
import io.branch.referral.util.BranchCPID;

public class BranchSDK extends CordovaPlugin {

Expand All @@ -41,6 +44,8 @@ static class BranchLinkProperties extends io.branch.referral.util.LinkProperties

// Standard Debugging Variables
private static final String LCAT = "CordovaBranchSDK";
// todo pick up plugin version dynamically
private static final String BRANCH_PLUGIN_VERSION = "4.1.0";

// Private Method Properties
private ArrayList<BranchUniversalObjectWrapper> branchObjectWrappers;
Expand Down Expand Up @@ -68,17 +73,19 @@ public BranchSDK() {
protected void pluginInitialize() {

this.activity = this.cordova.getActivity();

Branch.disableInstantDeepLinking(true);
Branch.getAutoInstance(this.activity.getApplicationContext());

BranchUtil.setPluginType(BranchUtil.PluginType.CordovaIonic);
BranchUtil.setPluginVersion(BRANCH_PLUGIN_VERSION);
if (this.instance == null) {
this.instance = Branch.getAutoInstance(this.activity.getApplicationContext());
}
}

/**
* Called when the activity receives a new intent.
*/
public void onNewIntent(Intent intent) {

intent.putExtra("branch_force_new_session", true);
this.activity.setIntent(intent);

this.reInitSession();
Expand Down Expand Up @@ -260,11 +267,15 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
}

public void crossPlatformIds(CallbackContext callbackContext) {
this.instance.getCrossPlatformIds(new BranchCPIDListener(callbackContext));
// stub call from known issue with caching
// this.instance.getCrossPlatformIds(new BranchCPIDListener(callbackContext));
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, false));
}

public void lastAttributedTouchData(CallbackContext callbackContext) {
this.instance.getLastAttributedTouchData(new BranchLATDListener(callbackContext), 30);
// stub call from known issue with caching
// this.instance.getLastAttributedTouchData(new BranchLATDListener(callbackContext), 30);
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, false));
}

//////////////////////////////////////////////////
Expand All @@ -288,7 +299,6 @@ private void initSession(CallbackContext callbackContext) {
}

this.sessionListener = new SessionListener(callbackContext);
this.instance = Branch.getAutoInstance(this.activity.getApplicationContext());
this.instance.initSession(this.sessionListener, data, activity);
}

Expand Down Expand Up @@ -609,10 +619,8 @@ private void setCookieBasedMatching(String linkDomain, CallbackContext callbackC

this.activity = this.cordova.getActivity();

Branch instance = Branch.getAutoInstance(this.activity.getApplicationContext());

if (linkDomain != null) {
instance.enableCookieBasedMatching(linkDomain);
Branch.enableCookieBasedMatching(linkDomain);
}

callbackContext.success("Success");
Expand All @@ -627,7 +635,7 @@ private void setCookieBasedMatching(String linkDomain, CallbackContext callbackC
*/
private void setDebug(boolean isEnable, CallbackContext callbackContext) {
this.activity = this.cordova.getActivity();
Branch.getAutoInstance(this.activity.getApplicationContext()).setDebug();
Branch.enableDebugMode();
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, isEnable));
}

Expand All @@ -641,7 +649,8 @@ private void setDebug(boolean isEnable, CallbackContext callbackContext) {
*/
private void disableTracking(boolean isEnable, CallbackContext callbackContext) {
this.activity = this.cordova.getActivity();
Branch.getAutoInstance(this.activity.getApplicationContext()).disableTracking(isEnable);

this.instance.disableTracking(isEnable);
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, isEnable));
}

Expand Down Expand Up @@ -888,15 +897,15 @@ public BranchUniversalObjectWrapper(BranchUniversalObject branchUniversalObj) {
//----------- INNER CLASS LISTENERS ------------//
//////////////////////////////////////////////////

protected class BranchCPIDListener implements BranchCrossPlatformId.BranchCrossPlatformIdListener {
protected class BranchCPIDListener implements BranchCrossPlatformIdListener {
private CallbackContext _callbackContext;

public BranchCPIDListener(CallbackContext callbackContext) {
this._callbackContext = callbackContext;
}

@Override
public void onDataFetched(BranchCrossPlatformId.BranchCPID branchCPID, BranchError error) {
public void onDataFetched(BranchCPID branchCPID, BranchError error) {
if (error != null) {
Log.d(LCAT, "CPID unavailable");
this._callbackContext.error("CPID unavailable");
Expand All @@ -921,7 +930,7 @@ public void onDataFetched(BranchCrossPlatformId.BranchCPID branchCPID, BranchErr
}
}

protected class BranchLATDListener implements BranchLastAttributedTouchData.BranchLastAttributedTouchDataListener {
protected class BranchLATDListener implements BranchLastAttributedTouchDataListener {
private CallbackContext _callbackContext;

public BranchLATDListener(CallbackContext callbackContext) {
Expand Down
3 changes: 3 additions & 0 deletions src/ios/AppDelegate+BranchSdk.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#import <Branch/Branch.h>
#endif

// Provides Ionic Capacitor compatibility
#import <Cordova/CDVPlugin.h>

@interface AppDelegate (BranchSDK)

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler;
Expand Down
13 changes: 8 additions & 5 deletions src/ios/BranchSDK.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#import "BranchSDK.h"

NSString * const pluginVersion = @"4.1.0";

@interface BranchSDK()

@property (strong, nonatomic) NSString *deepLinkUrl;
Expand Down Expand Up @@ -77,6 +79,7 @@ - (void)continueUserActivity:(CDVInvokedUrlCommand*)command

- (void)initSession:(CDVInvokedUrlCommand*)command
{
[[Branch getInstance] registerPluginName:"CordovaIonic" versio:pluginVersion];
[[Branch getInstance] initSessionWithLaunchOptions:nil andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {

NSString *resultString = nil;
Expand Down Expand Up @@ -746,7 +749,7 @@ - (void)listOnSpotlight:(CDVInvokedUrlCommand*)command {

- (void)crossPlatformIds:(CDVInvokedUrlCommand *)command {
NSMutableDictionary *json = [NSMutableDictionary new];

Branch *branch = [self getInstance];
[branch crossPlatformIdDataWithCompletion:^(BranchCrossPlatformID *cpid) {
CDVPluginResult* pluginResult = nil;
Expand All @@ -760,9 +763,9 @@ - (void)crossPlatformIds:(CDVInvokedUrlCommand *)command {
for (BranchProbabilisticCrossPlatformID *tmp in cpid.probabiliticCrossPlatformIDs) {
if (tmp.crossPlatformID && tmp.score) {
NSMutableDictionary *pair = [NSMutableDictionary new];
[pair setObject:tmp.crossPlatformID forKey:@"id"];
[pair setObject:tmp.crossPlatformID forKey:@"id"];
[pair setObject:tmp.score forKey:@"probability"];
[probCPIDs addObject:pair];
[probCPIDs addObject:pair];
}
}
[json setObject:probCPIDs forKey:@"prob_cross_platform_ids"];
Expand All @@ -777,9 +780,9 @@ - (void)crossPlatformIds:(CDVInvokedUrlCommand *)command {

- (void)lastAttributedTouchData:(CDVInvokedUrlCommand *)command {
NSMutableDictionary *json = [NSMutableDictionary new];

Branch *branch = [self getInstance];
[branch lastTouchAttributedDataWithCompletion:^(BranchLastAttributedTouchData * _Nullable latd) {
[branch lastAttributedTouchDataWithAttributionWindow:30 completion:^(BranchLastAttributedTouchData * _Nullable latd) {
CDVPluginResult* pluginResult = nil;
if (latd) {
[json setObject:latd.attributionWindow forKey:@"attribution_window"];
Expand Down
4 changes: 1 addition & 3 deletions src/scripts/hooks/beforePrepare.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
(function() {
(function () {
// properties

const configPreferences = require("../npm/processConfigXml.js");
const iosPlist = require("../ios/updatePlist.js");
const iosCapabilities = require("../ios/enableEntitlements.js");
const iosAssociatedDomains = require("../ios/updateAssociatedDomains.js");
const IOS = "ios";

Expand All @@ -18,7 +17,6 @@
platforms.forEach(platform => {
if (platform === IOS) {
iosPlist.addBranchSettings(preferences);
iosCapabilities.enableAssociatedDomains(preferences);
iosAssociatedDomains.addAssociatedDomains(preferences);
}
});
Expand Down
Loading

0 comments on commit c568eaa

Please sign in to comment.