capacitor-branch-deep-links
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -12,8 +12,63 @@ import { PluginListenerHandle } from '@capacitor/core'; | ||
} | ||
export interface BranchInitEvent { | ||
export interface BranchReferringParamsResponse { | ||
referringParams: BranchReferringParams; | ||
} | ||
export interface BranchShortUrlAnalytics { | ||
alias?: string; | ||
campaign?: string; | ||
channel?: string; | ||
duration?: number; | ||
feature?: string; | ||
stage?: string; | ||
tags?: Array<string>; | ||
} | ||
export interface BranchShortUrlProperties { | ||
'$desktop_url'?: string; | ||
'$android_url'?: string; | ||
'$ios_url'?: string; | ||
'$ipad_url'?: string; | ||
'$match_duration'?: number; | ||
'custom_string'?: string; | ||
'custom_integer'?: number; | ||
'custom_boolean'?: boolean; | ||
} | ||
export interface BranchShortUrlParams { | ||
analytics?: BranchShortUrlAnalytics; | ||
properties?: BranchShortUrlProperties; | ||
} | ||
export interface BranchShowShareSheetParams extends BranchShortUrlParams { | ||
shareText?: string; | ||
} | ||
export interface BranchShortUrlResponse { | ||
url: string; | ||
} | ||
export interface BranchTrackingResponse { | ||
is_enabled: boolean; | ||
} | ||
export interface BranchLoggedOutResponse { | ||
logged_out: boolean; | ||
} | ||
export interface BranchInitEvent extends BranchReferringParamsResponse { | ||
} | ||
export interface BranchDeepLinksPlugin { | ||
addListener(eventName: 'init', listenerFunc: (event: BranchInitEvent) => void): PluginListenerHandle; | ||
addListener(eventName: 'initError', listenerFunc: (error: any) => void): PluginListenerHandle; | ||
generateShortUrl(options: BranchShortUrlParams): Promise<BranchShortUrlResponse>; | ||
showShareSheet(options: BranchShowShareSheetParams): Promise<void>; | ||
getStandardEvents(): Promise<{ | ||
[index: number]: string; | ||
}>; | ||
sendBranchEvent(options: { | ||
eventName: string; | ||
metaData: { | ||
[key: string]: any; | ||
}; | ||
}): Promise<void>; | ||
disableTracking(options: { | ||
isEnabled: false; | ||
}): Promise<BranchTrackingResponse>; | ||
setIdentity(options: { | ||
newIdentity: string; | ||
}): Promise<BranchReferringParamsResponse>; | ||
logout(): Promise<BranchLoggedOutResponse>; | ||
} |
import { WebPlugin } from '@capacitor/core'; | ||
import { BranchDeepLinksPlugin } from './definitions'; | ||
import { BranchDeepLinksPlugin, BranchLoggedOutResponse, BranchReferringParamsResponse, BranchShortUrlParams, BranchShortUrlResponse, BranchShowShareSheetParams, BranchTrackingResponse } from './definitions'; | ||
export declare class BranchDeepLinksWeb extends WebPlugin implements BranchDeepLinksPlugin { | ||
constructor(); | ||
generateShortUrl(_: BranchShortUrlParams): Promise<BranchShortUrlResponse>; | ||
showShareSheet(_: BranchShowShareSheetParams): Promise<void>; | ||
getStandardEvents(): Promise<{ | ||
[index: number]: string; | ||
}>; | ||
sendBranchEvent(_: { | ||
eventName: string; | ||
metaData: { | ||
[key: string]: any; | ||
}; | ||
}): Promise<void>; | ||
disableTracking(_: { | ||
isEnabled: false; | ||
}): Promise<BranchTrackingResponse>; | ||
setIdentity(_: { | ||
newIdentity: string; | ||
}): Promise<BranchReferringParamsResponse>; | ||
logout(): Promise<BranchLoggedOutResponse>; | ||
} | ||
declare const BranchDeepLinks: BranchDeepLinksWeb; | ||
export { BranchDeepLinks }; |
@@ -9,2 +9,23 @@ import { WebPlugin } from '@capacitor/core'; | ||
} | ||
generateShortUrl(_) { | ||
return Promise.reject(new Error('BranchDeepLinks does not have web implementation')); | ||
} | ||
showShareSheet(_) { | ||
return Promise.reject(new Error('BranchDeepLinks does not have web implementation')); | ||
} | ||
getStandardEvents() { | ||
return Promise.reject(new Error('BranchDeepLinks does not have web implementation')); | ||
} | ||
sendBranchEvent(_) { | ||
return Promise.reject(new Error('BranchDeepLinks does not have web implementation')); | ||
} | ||
disableTracking(_) { | ||
return Promise.reject(new Error('BranchDeepLinks does not have web implementation')); | ||
} | ||
setIdentity(_) { | ||
return Promise.reject(new Error('BranchDeepLinks does not have web implementation')); | ||
} | ||
logout() { | ||
return Promise.reject(new Error('BranchDeepLinks does not have web implementation')); | ||
} | ||
} | ||
@@ -11,0 +32,0 @@ const BranchDeepLinks = new BranchDeepLinksWeb(); |
{ | ||
"name": "capacitor-branch-deep-links", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Capacitor plugin for Branch.io deep links", | ||
"main": "dist/esm/index.js", | ||
"main": "dist/plugin.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/esm/index.d.ts", | ||
"scripts": { | ||
"build": "npm run clean && tsc", | ||
"clean": "rm -rf ./dist", | ||
"lint": "npm run prettier -- --check && npm run swiftlint -- lint", | ||
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"", | ||
"swiftlint": "node-swiftlint", | ||
"build": "npm run clean && tsc && rollup -c rollup.config.js", | ||
"clean": "rimraf ./dist", | ||
"watch": "tsc --watch", | ||
"examples": "echo 'generate examples'; node ./src/scripts/examples", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"author": "Bound State Software", | ||
"author": "Bound State Software <info@boundstatesoftware.com>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@capacitor/core": "latest" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^3.2.4", | ||
"@capacitor/ios": "latest", | ||
"@capacitor/android": "latest" | ||
"@capacitor/android": "^2.4.0", | ||
"@capacitor/core": "^2.4.0", | ||
"@capacitor/ios": "^2.4.0", | ||
"@ionic/prettier-config": "^1.0.0", | ||
"@ionic/swiftlint-config": "^1.0.0", | ||
"@rollup/plugin-node-resolve": "^8.1.0", | ||
"prettier": "^2.0.5", | ||
"prettier-plugin-java": "^0.8.0", | ||
"rimraf": "^3.0.0", | ||
"rollup": "^2.21.0", | ||
"swiftlint": "^1.0.1", | ||
"typescript": "~3.8.3" | ||
}, | ||
"peerDependencies": { | ||
"@capacitor/core": "^2.4.0" | ||
}, | ||
"files": [ | ||
@@ -30,7 +44,8 @@ "dist/", | ||
"keywords": [ | ||
"branch.io", | ||
"capacitor", | ||
"capacitor-plugin", | ||
"deep-links", | ||
"plugin", | ||
"native", | ||
"branch.io", | ||
"deep link" | ||
"native" | ||
], | ||
@@ -45,9 +60,11 @@ "capacitor": { | ||
}, | ||
"prettier": "@ionic/prettier-config", | ||
"swiftlint": "@ionic/swiftlint-config", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/boundstate/capacitor-branch-deep-links" | ||
"url": "https://github.com/BranchMetrics/capacitor-branch-deep-links" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/boundstate/capacitor-branch-deep-links/issues" | ||
"url": "https://github.com/BranchMetrics/capacitor-branch-deep-links/issues" | ||
} | ||
} |
@@ -5,2 +5,4 @@ # capacitor-branch-deep-links | ||
[![Bound State Software](https://static.boundstatesoftware.com/github-badge.png)](https://boundstatesoftware.com) | ||
```sh | ||
@@ -12,34 +14,38 @@ npm install capacitor-branch-deep-links | ||
```typescript | ||
import { Plugins } from '@capacitor/core'; | ||
import { Platform } from '@ionic/angular'; | ||
import { BranchInitEvent } from 'capacitor-branch-deep-links'; | ||
```diff | ||
+ import { Plugins } from '@capacitor/core'; | ||
+ import { BranchInitEvent } from 'capacitor-branch-deep-links'; | ||
const { BranchDeepLinks, SplashScreen } = Plugins; | ||
+ const { BranchDeepLinks } = Plugins; | ||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
}) | ||
export class AppComponent { | ||
constructor(private platform: Platform) { | ||
this.initializeApp(); | ||
} | ||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: 'app.component.html', | ||
styleUrls: ['app.component.scss'] | ||
}) | ||
export class AppComponent { | ||
constructor( | ||
private platform: Platform, | ||
private splashScreen: SplashScreen, | ||
private statusBar: StatusBar | ||
) { | ||
this.initializeApp(); | ||
} | ||
initializeApp() { | ||
this.platform.ready().then(() => { | ||
BranchDeepLinks.addListener('init', (event: BranchInitEvent) => { | ||
// Retrieve deeplink keys from 'referringParams' and evaluate the values to determine where to route the user | ||
// Check '+clicked_branch_link' before deciding whether to use your Branch routing logic | ||
console.log(event.referringParams); | ||
}); | ||
initializeApp() { | ||
this.platform.ready().then(() => { | ||
this.statusBar.styleDefault(); | ||
this.splashScreen.hide(); | ||
+ BranchDeepLinks.addListener('init', (event: BranchInitEvent) => { | ||
+ // Retrieve deeplink keys from 'referringParams' and evaluate the values to determine where to route the user | ||
+ // Check '+clicked_branch_link' before deciding whether to use your Branch routing logic | ||
+ console.log(event.referringParams); | ||
+ }); | ||
BranchDeepLinks.addListener('initError', (error: any) => { | ||
console.error(error); | ||
+ BranchDeepLinks.addListener('initError', (error: any) => { | ||
+ console.error(error); | ||
+ }); | ||
}); | ||
SplashScreen.hide(); | ||
}); | ||
} | ||
} | ||
} | ||
``` | ||
@@ -53,2 +59,12 @@ | ||
If your app is in the Google Play Store, update `build.grade` with the necessary dependencies: | ||
```diff | ||
dependencies { | ||
+ implementation 'com.android.installreferrer:installreferrer:1.1' | ||
+ implementation 'com.google.android.gms:play-services-appindexing:9.+' // App indexing | ||
+ implementation 'com.google.android.gms:play-services-ads:9+' // GAID matching | ||
} | ||
``` | ||
Update `src/main/res/values/strings.xml` with your configuration: | ||
@@ -72,2 +88,3 @@ | ||
```diff | ||
+ import android.content.Intent; | ||
+ import co.boundstate.BranchDeepLinks; | ||
@@ -87,2 +104,8 @@ | ||
} | ||
+ @Override | ||
+ protected void onNewIntent(Intent intent) { | ||
+ this.setIntent(intent); | ||
+ super.onNewIntent(intent); | ||
+ } | ||
} | ||
@@ -106,3 +129,3 @@ ``` | ||
Add your Branch App Links (optional) in a new `<intent-filter>` within `<application>`: | ||
Add your Branch App Links (optional) in a new `<intent-filter>` within `<activity>`: | ||
@@ -134,12 +157,2 @@ ```xml | ||
Add Branch to your `Podfile`: | ||
```diff | ||
target 'App' do | ||
capacitor_pods | ||
# Add your Pods here | ||
+ pod 'Branch'; | ||
end | ||
``` | ||
Update the project: | ||
@@ -159,3 +172,3 @@ | ||
+ Branch.setUseTestBranchKey(true) // if you are using the TEST key | ||
+ Branch.getInstance()!.initSession(launchOptions: launchOptions) | ||
+ Branch.getInstance().initSession(launchOptions: launchOptions) | ||
return true | ||
@@ -167,3 +180,3 @@ } | ||
// but if you want the App API to support tracking app url opens, make sure to keep this call | ||
+ Branch.getInstance()!.application(app, open: url, options: options) | ||
+ Branch.getInstance().application(app, open: url, options: options) | ||
return CAPBridge.handleOpenUrl(url, options) | ||
@@ -176,7 +189,11 @@ } | ||
// tracking app url opens, make sure to keep this call | ||
+ Branch.getInstance()!.continue(userActivity) | ||
+ Branch.getInstance().continue(userActivity) | ||
return CAPBridge.handleContinueActivity(userActivity, restorationHandler) | ||
} | ||
+ func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { | ||
+ Branch.getInstance().handlePushNotification(userInfo) | ||
+ } | ||
``` | ||
[Test that it works!](https://docs.branch.io/apps/ios/#test-deep-link) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 15 instances in 1 package
173
190
1
147534
12
47
1
+ Added@capacitor/core@2.5.0(transitive)
+ Addedtslib@1.14.1(transitive)
- Removed@capacitor/core@latest
- Removed@capacitor/core@6.2.0(transitive)
- Removedtslib@2.8.1(transitive)