Configuration
Deep links are configured inconfig/nativephp.php:
.env file:
Applying Changes
After configuring deep links, rebuild the native configuration:URL Scheme Deep Links
URL scheme deep links use a custom protocol to open your app:Choosing a URL Scheme
Your URL scheme should be:- Unique: Avoid conflicts with other apps
- Lowercase: Use only lowercase letters
- Memorable: Easy for users to recognize
- Branded: Related to your app or company name
nativephp://mystore://acmecorp://
- Common words (
app://,open://) - Generic terms (
link://,mobile://) - Existing schemes (
http://,mailto://)
Configuring URL Scheme
myapp://homemyapp://products/123myapp://settings?tab=account
Testing URL Schemes
iOS:HTTPS Deep Links (Universal Links)
HTTPS deep links allow regular web URLs to open your app when tapped:Configuring HTTPS Deep Links
https://example.com/homehttps://example.com/products/123https://example.com/settings?tab=account
Platform Requirements
iOS (Universal Links)
iOS Universal Links require hosting anapple-app-site-association file on your domain:
File location:
TEAM_IDwith your Apple Developer Team IDcom.example.appwith your app’s bundle identifier["*"]with specific paths if you don’t want all URLs to open the app
- File must be served over HTTPS
- Content-Type must be
application/json - No redirects allowed
- File must be accessible without authentication
Android (App Links)
Android App Links require hosting aassetlinks.json file:
File location:
com.example.appwith your app’s package nameYOUR_CERTIFICATE_FINGERPRINTwith your app signing certificate’s SHA-256 fingerprint
- File must be served over HTTPS
- Content-Type must be
application/json - File must be accessible without authentication
Handling Deep Links in Your App
When a deep link opens your app, NativePHP dispatches it as a Laravel route.Defining Deep Link Routes
Handle deep links in yourroutes/web.php or routes/native.php:
Detecting Deep Link Launches
Deep links are handled through Laravel’s routing system. When a user taps a deep link, your app opens and Laravel routes the request to the appropriate controller or page.Handling Deep Links with Routes
Define routes that match your deep link structure:Livewire Deep Link Handling
Handle deep link parameters in Livewire components:Redirecting After Deep Link
Redirect to a specific page when a deep link is received:NFC Tag Integration
NFC functionality is not currently provided as a built-in facade in NativePHP Mobile. You can implement NFC support using custom plugins.
NFC Deep Link Flow
Setting Up NFC Tags
To enable NFC deep links:- Write your app’s deep link URL to an NFC tag using an NFC writing app
- Ensure the URL matches your configured
deeplink_host - Configure proper domain verification files (see HTTPS Deep Links section above)
NFC Tag Best Practices
Use HTTPS URLs for NFC tags
Use HTTPS URLs for NFC tags
Keep URLs short
Keep URLs short
NFC tags have limited storage. Use short, clean URLs.
Test NFC tags on both platforms
Test NFC tags on both platforms
Provide fallback content
Provide fallback content
Ensure the URL works in a browser for users who don’t have the app installed.
Advanced Deep Link Patterns
Parameter Extraction
Extract parameters from deep link URLs:Query Parameters
Handle query parameters in deep links:Authentication Gates
Protect deep link routes with authentication:Dynamic Deep Link Generation
Generate deep links programmatically:Sharing Deep Links
Share deep links via the native share sheet:Testing Deep Links
Testing in Development
iOS Simulator:Testing on Physical Devices
- Send yourself an email or message with the deep link
- Tap the link in the email/message
- Verify the app opens and handles the link correctly
Testing HTTPS Deep Links
HTTPS deep links require:- App installed from App Store/Play Store (or signed with release certificate)
- Domain verification files properly configured
- Domain accessible over HTTPS
Troubleshooting
URL scheme deep links not working
- Verify
NATIVEPHP_DEEPLINK_SCHEMEis set in.env - Run
php artisan native:install --force - Rebuild and reinstall the app
- Test with the correct URL format:
scheme://path
HTTPS deep links not opening app
- Verify domain verification files are accessible:
https://example.com/.well-known/apple-app-site-associationhttps://example.com/.well-known/assetlinks.json
- Ensure files are served over HTTPS with no redirects
- Verify app is signed with release certificate or installed from store
- Check Team ID and bundle identifier (iOS) or package name and certificate fingerprint (Android)
NFC tags not opening app
- Ensure NFC is enabled on the device
- Verify the NFC tag contains a valid URL that matches your configured domain
- Test the URL in a browser first to ensure it works
- Verify domain verification files are properly configured
Deep link routes not found
- Verify routes are defined in
routes/web.php - Check that route parameters match the URL structure
- Test the route directly in your app first
- Clear Laravel route cache:
php artisan route:clear
Best Practices
Use both URL schemes and HTTPS
Use both URL schemes and HTTPS
Configure both for maximum compatibility. URL schemes work everywhere, HTTPS deep links provide a better user experience.
Keep paths consistent
Keep paths consistent
Use the same URL structure for web, deep links, and NFC tags.
Handle missing parameters gracefully
Handle missing parameters gracefully
Always validate and provide defaults for deep link parameters.
Test on physical devices
Test on physical devices
HTTPS deep links only work correctly on physical devices with proper signing.
Provide fallback pages
Provide fallback pages
Ensure your HTTPS deep link URLs work in a browser for users without the app.
Log deep link events
Log deep link events
Track which deep links are used to understand user behavior.
Next Steps
Share
Share deep links via the native share sheet
Browser
Open URLs and handle OAuth flows