|
| 1 | +--- |
| 2 | +title: Deep, Universal, App Links and NFC |
| 3 | +order: 900 |
| 4 | +--- |
| 5 | + |
| 6 | +## Overview |
| 7 | + |
| 8 | +NativePHP for Mobile supports both **deep linking** and **web-based linking** into your mobile apps. |
| 9 | + |
| 10 | +There are two types of link integrations you can configure: |
| 11 | + |
| 12 | +- **Deep Links** (myapp://some/path) |
| 13 | +- **Universal Links (iOS)** and **App Links (Android)** (https://yourdomain.com/some/path) |
| 14 | + |
| 15 | +Each method has its use case, and NativePHP allows you to configure and handle both easily. |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Deep Links |
| 20 | + |
| 21 | +Deep links use a **custom URL scheme** to open your app. |
| 22 | + |
| 23 | +For example: |
| 24 | + |
| 25 | +``` |
| 26 | +myapp://profile/123 |
| 27 | +``` |
| 28 | + |
| 29 | + |
| 30 | +When a user taps a deep link, the mobile operating system detects the custom scheme and opens your app directly. |
| 31 | + |
| 32 | +### Configuration |
| 33 | + |
| 34 | +To enable deep linking, you must define: |
| 35 | + |
| 36 | +- **Scheme**: The protocol (e.g., myapp) |
| 37 | +- **Host**: An optional domain-like segment (e.g., open) |
| 38 | + |
| 39 | +These are configured in your .env: |
| 40 | + |
| 41 | +```dotenv |
| 42 | +NATIVEPHP_DEEPLINK_SCHEME=myapp |
| 43 | +NATIVEPHP_DEEPLINK_HOST=open |
| 44 | +``` |
| 45 | + |
| 46 | +## Universal Links (iOS) and App Links (Android) |
| 47 | + |
| 48 | +Universal Links and App Links allow real HTTPS URLs to open your app instead of a web browser, if the app is installed. |
| 49 | + |
| 50 | +For example: |
| 51 | +```dotenv |
| 52 | +https://bifrost.tech/property/456 |
| 53 | +``` |
| 54 | + |
| 55 | +When a user taps this link: |
| 56 | + |
| 57 | + - If your app is installed, it opens directly into the app. |
| 58 | + - If not, it opens normally in the browser. |
| 59 | + |
| 60 | +This provides a seamless user experience without needing a custom scheme. |
| 61 | + |
| 62 | +### How It Works |
| 63 | +1. You must prove to iOS and Android that you own the domain by hosting a special file: |
| 64 | + - .well-known/apple-app-site-association (for iOS) |
| 65 | + - .well-known/assetlinks.json (for Android) |
| 66 | +2. The mobile OS reads these files to verify the link association. |
| 67 | +3. Once verified, tapping a real URL will open your app instead of Safari or Chrome. |
| 68 | + |
| 69 | +NativePHP for Mobile handles all of this for you. |
| 70 | + |
| 71 | +### Configuration |
| 72 | + |
| 73 | +To enable Universal Links and App Links, you must define: |
| 74 | + |
| 75 | +- **Host**: The domain name (e.g., bifrost-tech.com) |
| 76 | + |
| 77 | +These are configured in your .env: |
| 78 | + |
| 79 | +```dotenv |
| 80 | +NATIVEPHP_DEEPLINK_HOST=bifrost-tech.com |
| 81 | +``` |
| 82 | + |
| 83 | +## Handling Universal/App Links |
| 84 | + |
| 85 | +Once you've configured your deep link settings, you can handle the link in your app. |
| 86 | + |
| 87 | +Simply setup a route in your web.php file and the deeplink will redirect to your route. |
| 88 | + |
| 89 | +```dotenv |
| 90 | +https://bifrost-tech.com/profile/123 |
| 91 | +``` |
| 92 | + |
| 93 | +```php |
| 94 | +Route::get('/profile/{id}', function ($id) { |
| 95 | + // Handle the deep link |
| 96 | +}); |
| 97 | +``` |
| 98 | + |
| 99 | +## NFC |
| 100 | +NFC is a technology that allows you to read and write NFC tags. |
| 101 | + |
| 102 | +NativePHP handles NFC tag "bumping" just like a Universal/App Link. |
| 103 | +You can use a tool like [NFC Tools](https://www.wakdev.com/en/) to test write NFC tags. |
| 104 | + |
| 105 | +Set the url to a Universal/App Link and the tag will be written to the NFC tag. |
| 106 | +"Bumping" the tag will open the app. |
| 107 | + |
| 108 | + |
| 109 | + |
0 commit comments