|
| 1 | +# Branch.io |
| 2 | + |
| 3 | +Deep linking, mobile attribution, and analytics with Branch.io for NativeScript apps. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install @nstudio/nativescript-branch |
| 9 | +``` |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +Import `BranchIO` from your app's main entry point and call the `initSession` method before the app launches: |
| 14 | + |
| 15 | +```typescript |
| 16 | +import { BranchIO } from '@nstudio/nativescript-branch'; |
| 17 | + |
| 18 | +BranchIO.initSession(); |
| 19 | +``` |
| 20 | + |
| 21 | +## Configuration |
| 22 | + |
| 23 | +### Android Setup |
| 24 | + |
| 25 | +Follow the [Android basic integration guide](https://help.branch.io/developers-hub/docs/android-basic-integration#4-configure-app) to configure your Android app. |
| 26 | + |
| 27 | +Key steps: |
| 28 | +1. Add your Branch key to your Android manifest |
| 29 | +2. Configure deep link routing |
| 30 | +3. Add intent filters for your URL schemes |
| 31 | + |
| 32 | +### iOS Setup |
| 33 | + |
| 34 | +Follow the [iOS basic integration guide](https://help.branch.io/developers-hub/docs/ios-basic-integration) to configure your iOS app. |
| 35 | + |
| 36 | +Key steps: |
| 37 | +1. Add your Branch key to Info.plist |
| 38 | +2. Configure Associated Domains |
| 39 | +3. Handle Universal Links |
| 40 | + |
| 41 | +## Features |
| 42 | + |
| 43 | +Branch.io provides powerful features for mobile apps: |
| 44 | + |
| 45 | +- **Deep Linking** - Direct users to specific content within your app |
| 46 | +- **Attribution** - Track where your users come from |
| 47 | +- **Analytics** - Understand user behavior and campaign performance |
| 48 | +- **Smart Banners** - Display smart app banners on mobile web |
| 49 | +- **QR Codes** - Generate and track QR code campaigns |
| 50 | + |
| 51 | +## API Reference |
| 52 | + |
| 53 | +### `BranchIO.initSession()` |
| 54 | + |
| 55 | +Initialize the Branch session. Call this method from your app's main entry point before the app launches. |
| 56 | + |
| 57 | +```typescript |
| 58 | +import { BranchIO } from '@nstudio/nativescript-branch'; |
| 59 | + |
| 60 | +// Initialize Branch |
| 61 | +BranchIO.initSession(); |
| 62 | +``` |
| 63 | + |
| 64 | +## Deep Link Handling |
| 65 | + |
| 66 | +Branch allows you to handle deep links and route users to the appropriate content: |
| 67 | + |
| 68 | +```typescript |
| 69 | +import { BranchIO } from '@nstudio/nativescript-branch'; |
| 70 | + |
| 71 | +// Listen for deep link data |
| 72 | +BranchIO.initSession((params) => { |
| 73 | + if (params['+clicked_branch_link']) { |
| 74 | + // User clicked a Branch link |
| 75 | + console.log('Deep link data:', params); |
| 76 | + |
| 77 | + // Route user based on deep link parameters |
| 78 | + if (params.product_id) { |
| 79 | + // Navigate to product page |
| 80 | + } |
| 81 | + } |
| 82 | +}); |
| 83 | +``` |
| 84 | + |
| 85 | +## Creating Branch Links |
| 86 | + |
| 87 | +Create Branch links programmatically to share content: |
| 88 | + |
| 89 | +```typescript |
| 90 | +const linkProperties = { |
| 91 | + feature: 'sharing', |
| 92 | + channel: 'email', |
| 93 | + campaign: 'product-launch', |
| 94 | + tags: ['tag1', 'tag2'] |
| 95 | +}; |
| 96 | + |
| 97 | +const branchUniversalObject = { |
| 98 | + canonicalIdentifier: 'product/123', |
| 99 | + title: 'Product Name', |
| 100 | + contentDescription: 'Product description', |
| 101 | + contentImageUrl: 'https://example.com/image.jpg' |
| 102 | +}; |
| 103 | + |
| 104 | +// Generate a Branch link |
| 105 | +const link = await BranchIO.generateShortUrl( |
| 106 | + branchUniversalObject, |
| 107 | + linkProperties |
| 108 | +); |
| 109 | +console.log('Share link:', link); |
| 110 | +``` |
| 111 | + |
| 112 | +## Learn More |
| 113 | + |
| 114 | +For complete documentation, visit the [Branch.io developers hub](https://help.branch.io/developers-hub/docs): |
| 115 | + |
| 116 | +- [Android Integration](https://help.branch.io/developers-hub/docs/android-basic-integration) |
| 117 | +- [iOS Integration](https://help.branch.io/developers-hub/docs/ios-basic-integration) |
| 118 | +- [Branch Dashboard](https://dashboard.branch.io/) |
| 119 | + |
| 120 | +## License |
| 121 | + |
| 122 | +Apache License Version 2.0 |
0 commit comments