
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
capacitor-branch-deep-links
Advanced tools
Capacitor plugin for branch.io deep links.
npm install capacitor-branch-deep-links
import { Plugins } from '@capacitor/core';
import { Platform } from '@ionic/angular';
import { BranchInitEvent } from 'capacitor-branch-deep-links';
const { BranchDeepLinks, SplashScreen } = Plugins;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
})
export class AppComponent {
constructor(private platform: Platform) {
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);
});
BranchDeepLinks.addListener('initError', (error: any) => {
console.error(error);
});
SplashScreen.hide();
});
}
}
Follow the Branch docs to:
Update src/main/res/values/strings.xml
with your configuration:
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">Ionic Starter</string>
<string name="title_activity_main">Ionic Starter</string>
<string name="package_name">io.ionic.starter</string>
<string name="fileprovider_authority">io.ionic.starter.fileprovider</string>
+ <string name="custom_url_scheme">io.ionic.starter</string>
+ <string name="branch_key">key_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</string>
+ <string name="branch_test_key">key_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</string>
</resources>
Register the plugin in your Activity:
+ import co.boundstate.BranchDeepLinks;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
+ add(BranchDeepLinks.class);
}});
}
}
Declare BranchApp
as your application class in src/main/AndroidManifest.xml
:
<application
+ android:name="io.branch.referral.BranchApp"
Provide your Branch config within <application>
:
<meta-data android:name="io.branch.sdk.BranchKey" android:value="@string/branch_key" />
<meta-data android:name="io.branch.sdk.BranchKey.test" android:value="@string/branch_test_key" />
<meta-data android:name="io.branch.sdk.TestMode" android:value="false" /> <!-- Set to true to use test key -->
Add your Branch App Links (optional) in a new <intent-filter>
within <application>
:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="xxxx.app.link" />
<data android:scheme="https" android:host="xxxx-alternate.app.link" />
</intent-filter>
Follow the Branch docs to:
You can use the Branch wizard to walk you through the process
(skip the Get the SDK files and Start a Branch session steps)
Add Branch to your Podfile
:
target 'App' do
capacitor_pods
# Add your Pods here
+ pod 'Branch';
end
Update the project:
npx cap update ios
Make the following changes to your AppDelegate.swift
file:
+ import Branch
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
+ Branch.setUseTestBranchKey(true) // if you are using the TEST key
+ Branch.getInstance()!.initSession(launchOptions: launchOptions)
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// Called when the app was launched with a url. Feel free to add additional processing here,
// 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)
return CAPBridge.handleOpenUrl(url, options)
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// Called when the app was launched with an activity, including Universal Links.
// Feel free to add additional processing here, but if you want the App API to support
// tracking app url opens, make sure to keep this call
+ Branch.getInstance()!.continue(userActivity)
return CAPBridge.handleContinueActivity(userActivity, restorationHandler)
}
FAQs
Capacitor plugin for Branch.io deep links
The npm package capacitor-branch-deep-links receives a total of 2,256 weekly downloads. As such, capacitor-branch-deep-links popularity was classified as popular.
We found that capacitor-branch-deep-links demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.