Skip to content

Commit c568eaa

Browse files
Merge pull request #618 from BranchMetrics/staging
Release 4.0.1
2 parents 354d023 + a565c9d commit c568eaa

File tree

10 files changed

+110
-162
lines changed

10 files changed

+110
-162
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ package-lock.json
88
npm-debug.log*
99
yarn-error.log*
1010
.vscode
11+
.idea
12+
src/android/.idea

README.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ _Questions? [Contact us](https://support.branch.io/support/tickets/new)_
5555
* [Compiling: Updating the Branch SDK](#compiling-updating-the-branch-sdk)
5656
* [Compiling: Incompatible Plugins](#compiling-incompatible-plugins)
5757
* [Compiling: Errors](#compiling-errors)
58+
* [Compiling: Capacitor](#compiling-capacitor)
59+
* [AppStore: iOS](#appstore-ios)
5860

5961
## Getting Started
6062

@@ -727,7 +729,6 @@ _Questions? [Contact us](https://support.branch.io/support/tickets/new)_
727729
<link-domain value="bnc.lt" /> <!-- optional previous link domain -->
728730
<ios-team-release value="PW4Q8885U7" /> <!-- required if iOS app -->
729731
<ios-team-debug value="FG35JLLMXX" /> <!-- optional -->
730-
<android-prefix value="/WSuf" /> <!-- optional (for bnc.lt link domains) -->
731732
<android-testmode value="true" /> <!-- optional (simulate installs) -->
732733
</branch-config>
733734
```
@@ -1348,3 +1349,61 @@ _Questions? [Contact us](https://support.branch.io/support/tickets/new)_
13481349
```
13491350
13501351
* Add `<preference name="android-minSdkVersion" value="16" />` to your `config.xml`
1352+
1353+
* error
1354+
1355+
```sh
1356+
Branch.h not found
1357+
```
1358+
If that is the ONLY error you see, this can be fixed by upgrading dependencies.
1359+
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.
1360+
1361+
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.
1362+
1363+
* error: ios build fails with Pods and CONFIGURATION_BUILD_DIR configured
1364+
1365+
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.
1366+
1367+
* #### Compiling: Capacitor
1368+
1369+
* ##### Version 4.0.1 of this plugin works with Ionic 4 + Cordova and Ionic 4 + Capacitor, with the following caveats:
1370+
1371+
* We strongly recommend Node >= 10.15. Node 8 might work, but it is not tested.
1372+
* 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
1373+
* Every single one of these dependencies has fixes that allow the command line build, and the pod dependency resolution to work correctly
1374+
* You MUST use @capacitor/ios >= 1.4.0. Versions prior to that version did not federate the OpenURL notifications to other plugins, including Branch.
1375+
* `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.
1376+
* When using Capacitor, you must add the following entries yourself to `ios/App/App/Info.plist`:
1377+
```sh
1378+
<key>CFBundleURLTypes</key>
1379+
<array>
1380+
<dict>
1381+
<key>CFBundleURLName</key>
1382+
<string>com.getcapacitor.capacitor</string>
1383+
<key>CFBundleURLSchemes</key>
1384+
<array>
1385+
<string>capacitor</string>
1386+
</array>
1387+
</dict>
1388+
<dict>
1389+
<key>CFBundleURLName</key>
1390+
<string>branch-cordova-sdk</string>
1391+
<key>CFBundleURLSchemes</key>
1392+
<array>
1393+
<string>[YOUR URL SCHEME HERE]</string>
1394+
</array>
1395+
</dict>
1396+
</array>
1397+
<key>branch_key</key>
1398+
<string>[YOUR BRANCH LIVE KEY]</string>
1399+
<key>branch_app_domain</key>
1400+
<string>[YOUR DOMAIN].app.link</string>
1401+
```
1402+
* When using Capacitor, you must add your Associated Domains entitlements via the Xcode entitlement editor yourself
1403+
* This MUST be done using Xcode - this is part of Capacitor's philosophy whereby you are in control of every config file change
1404+
* Open the "Signing & Entitlements" tab in Xcode, add the Associated Domains entitlement, and add the urls found on your Branch dashboard.
1405+
1406+
* #### AppStore: iOS
1407+
1408+
* #### App rejected because it uses push notification features but does not declare the aps-environment key
1409+
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.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "branch-cordova-sdk",
33
"description": "Branch Metrics Cordova SDK",
44
"main": "src/index.js",
5-
"version": "4.0.0",
5+
"version": "4.1.0",
66
"homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking",
77
"repository": {
88
"type": "git",
@@ -17,7 +17,7 @@
1717
],
1818
"license": "MIT",
1919
"engines": [
20-
{
20+
{
2121
"name": "cordova",
2222
"version": ">=9.0.0"
2323
}

plugin.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SOFTWARE.
2424
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2525
xmlns:android="http://schemas.android.com/apk/res/android"
2626
id="branch-cordova-sdk"
27-
version="4.0.0">
27+
version="4.1.0">
2828

2929
<!-- Description -->
3030
<name>branch-cordova-sdk</name>
@@ -36,7 +36,7 @@ SOFTWARE.
3636

3737
<!-- Dependencies -->
3838
<engines>
39-
<engine name="cordova" version=">=3.5.0" />
39+
<engine name="cordova" version=">=9.0.0" />
4040
</engines>
4141

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

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

6868
<!-- iOS -->
@@ -85,8 +85,8 @@ SOFTWARE.
8585
<config>
8686
<source url="https://github.com/CocoaPods/Specs.git"/>
8787
</config>
88-
<pods use-frameworks="true">
89-
<pod name="Branch" spec="~> 0.29.0" />
88+
<pods>
89+
<pod name="Branch" spec="~> 0.31.3" />
9090
</pods>
9191
</podspec>
9292
</platform>

src/android/io/branch/BranchSDK.java

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import io.branch.indexing.BranchUniversalObject;
2222
import io.branch.referral.Branch;
23+
import io.branch.referral.BranchUtil;
24+
import io.branch.referral.PrefHelper;
2325
import io.branch.referral.BranchError;
2426
import io.branch.referral.BranchViewHandler;
2527
import io.branch.referral.SharingHelper;
@@ -31,8 +33,9 @@
3133
import io.branch.referral.util.ProductCategory;
3234
import io.branch.referral.util.ShareSheetStyle;
3335

34-
import io.branch.referral.util.BranchCrossPlatformId;
35-
import io.branch.referral.util.BranchLastAttributedTouchData;
36+
import io.branch.referral.ServerRequestGetLATD.BranchLastAttributedTouchDataListener;
37+
import io.branch.referral.ServerRequestGetCPID.BranchCrossPlatformIdListener;
38+
import io.branch.referral.util.BranchCPID;
3639

3740
public class BranchSDK extends CordovaPlugin {
3841

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

4245
// Standard Debugging Variables
4346
private static final String LCAT = "CordovaBranchSDK";
47+
// todo pick up plugin version dynamically
48+
private static final String BRANCH_PLUGIN_VERSION = "4.1.0";
4449

4550
// Private Method Properties
4651
private ArrayList<BranchUniversalObjectWrapper> branchObjectWrappers;
@@ -68,17 +73,19 @@ public BranchSDK() {
6873
protected void pluginInitialize() {
6974

7075
this.activity = this.cordova.getActivity();
71-
7276
Branch.disableInstantDeepLinking(true);
73-
Branch.getAutoInstance(this.activity.getApplicationContext());
74-
77+
BranchUtil.setPluginType(BranchUtil.PluginType.CordovaIonic);
78+
BranchUtil.setPluginVersion(BRANCH_PLUGIN_VERSION);
79+
if (this.instance == null) {
80+
this.instance = Branch.getAutoInstance(this.activity.getApplicationContext());
81+
}
7582
}
7683

7784
/**
7885
* Called when the activity receives a new intent.
7986
*/
8087
public void onNewIntent(Intent intent) {
81-
88+
intent.putExtra("branch_force_new_session", true);
8289
this.activity.setIntent(intent);
8390

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

262269
public void crossPlatformIds(CallbackContext callbackContext) {
263-
this.instance.getCrossPlatformIds(new BranchCPIDListener(callbackContext));
270+
// stub call from known issue with caching
271+
// this.instance.getCrossPlatformIds(new BranchCPIDListener(callbackContext));
272+
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, false));
264273
}
265274

266275
public void lastAttributedTouchData(CallbackContext callbackContext) {
267-
this.instance.getLastAttributedTouchData(new BranchLATDListener(callbackContext), 30);
276+
// stub call from known issue with caching
277+
// this.instance.getLastAttributedTouchData(new BranchLATDListener(callbackContext), 30);
278+
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, false));
268279
}
269280

270281
//////////////////////////////////////////////////
@@ -288,7 +299,6 @@ private void initSession(CallbackContext callbackContext) {
288299
}
289300

290301
this.sessionListener = new SessionListener(callbackContext);
291-
this.instance = Branch.getAutoInstance(this.activity.getApplicationContext());
292302
this.instance.initSession(this.sessionListener, data, activity);
293303
}
294304

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

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

612-
Branch instance = Branch.getAutoInstance(this.activity.getApplicationContext());
613-
614622
if (linkDomain != null) {
615-
instance.enableCookieBasedMatching(linkDomain);
623+
Branch.enableCookieBasedMatching(linkDomain);
616624
}
617625

618626
callbackContext.success("Success");
@@ -627,7 +635,7 @@ private void setCookieBasedMatching(String linkDomain, CallbackContext callbackC
627635
*/
628636
private void setDebug(boolean isEnable, CallbackContext callbackContext) {
629637
this.activity = this.cordova.getActivity();
630-
Branch.getAutoInstance(this.activity.getApplicationContext()).setDebug();
638+
Branch.enableDebugMode();
631639
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, isEnable));
632640
}
633641

@@ -641,7 +649,8 @@ private void setDebug(boolean isEnable, CallbackContext callbackContext) {
641649
*/
642650
private void disableTracking(boolean isEnable, CallbackContext callbackContext) {
643651
this.activity = this.cordova.getActivity();
644-
Branch.getAutoInstance(this.activity.getApplicationContext()).disableTracking(isEnable);
652+
653+
this.instance.disableTracking(isEnable);
645654
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, isEnable));
646655
}
647656

@@ -888,15 +897,15 @@ public BranchUniversalObjectWrapper(BranchUniversalObject branchUniversalObj) {
888897
//----------- INNER CLASS LISTENERS ------------//
889898
//////////////////////////////////////////////////
890899

891-
protected class BranchCPIDListener implements BranchCrossPlatformId.BranchCrossPlatformIdListener {
900+
protected class BranchCPIDListener implements BranchCrossPlatformIdListener {
892901
private CallbackContext _callbackContext;
893902

894903
public BranchCPIDListener(CallbackContext callbackContext) {
895904
this._callbackContext = callbackContext;
896905
}
897906

898907
@Override
899-
public void onDataFetched(BranchCrossPlatformId.BranchCPID branchCPID, BranchError error) {
908+
public void onDataFetched(BranchCPID branchCPID, BranchError error) {
900909
if (error != null) {
901910
Log.d(LCAT, "CPID unavailable");
902911
this._callbackContext.error("CPID unavailable");
@@ -921,7 +930,7 @@ public void onDataFetched(BranchCrossPlatformId.BranchCPID branchCPID, BranchErr
921930
}
922931
}
923932

924-
protected class BranchLATDListener implements BranchLastAttributedTouchData.BranchLastAttributedTouchDataListener {
933+
protected class BranchLATDListener implements BranchLastAttributedTouchDataListener {
925934
private CallbackContext _callbackContext;
926935

927936
public BranchLATDListener(CallbackContext callbackContext) {

src/ios/AppDelegate+BranchSdk.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#import <Branch/Branch.h>
99
#endif
1010

11+
// Provides Ionic Capacitor compatibility
12+
#import <Cordova/CDVPlugin.h>
13+
1114
@interface AppDelegate (BranchSDK)
1215

1316
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler;

src/ios/BranchSDK.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#import "BranchSDK.h"
22

3+
NSString * const pluginVersion = @"4.1.0";
4+
35
@interface BranchSDK()
46

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

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

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

747750
- (void)crossPlatformIds:(CDVInvokedUrlCommand *)command {
748751
NSMutableDictionary *json = [NSMutableDictionary new];
749-
752+
750753
Branch *branch = [self getInstance];
751754
[branch crossPlatformIdDataWithCompletion:^(BranchCrossPlatformID *cpid) {
752755
CDVPluginResult* pluginResult = nil;
@@ -760,9 +763,9 @@ - (void)crossPlatformIds:(CDVInvokedUrlCommand *)command {
760763
for (BranchProbabilisticCrossPlatformID *tmp in cpid.probabiliticCrossPlatformIDs) {
761764
if (tmp.crossPlatformID && tmp.score) {
762765
NSMutableDictionary *pair = [NSMutableDictionary new];
763-
[pair setObject:tmp.crossPlatformID forKey:@"id"];
766+
[pair setObject:tmp.crossPlatformID forKey:@"id"];
764767
[pair setObject:tmp.score forKey:@"probability"];
765-
[probCPIDs addObject:pair];
768+
[probCPIDs addObject:pair];
766769
}
767770
}
768771
[json setObject:probCPIDs forKey:@"prob_cross_platform_ids"];
@@ -777,9 +780,9 @@ - (void)crossPlatformIds:(CDVInvokedUrlCommand *)command {
777780

778781
- (void)lastAttributedTouchData:(CDVInvokedUrlCommand *)command {
779782
NSMutableDictionary *json = [NSMutableDictionary new];
780-
783+
781784
Branch *branch = [self getInstance];
782-
[branch lastTouchAttributedDataWithCompletion:^(BranchLastAttributedTouchData * _Nullable latd) {
785+
[branch lastAttributedTouchDataWithAttributionWindow:30 completion:^(BranchLastAttributedTouchData * _Nullable latd) {
783786
CDVPluginResult* pluginResult = nil;
784787
if (latd) {
785788
[json setObject:latd.attributionWindow forKey:@"attribution_window"];

src/scripts/hooks/beforePrepare.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
(function() {
1+
(function () {
22
// properties
33

44
const configPreferences = require("../npm/processConfigXml.js");
55
const iosPlist = require("../ios/updatePlist.js");
6-
const iosCapabilities = require("../ios/enableEntitlements.js");
76
const iosAssociatedDomains = require("../ios/updateAssociatedDomains.js");
87
const IOS = "ios";
98

@@ -18,7 +17,6 @@
1817
platforms.forEach(platform => {
1918
if (platform === IOS) {
2019
iosPlist.addBranchSettings(preferences);
21-
iosCapabilities.enableAssociatedDomains(preferences);
2220
iosAssociatedDomains.addAssociatedDomains(preferences);
2321
}
2422
});

0 commit comments

Comments
 (0)