Skip to content

Commit 033fd97

Browse files
committed
Update mobile documentation with enhanced deep links, push notifications, and database seeding
- Enhanced deep links documentation with comprehensive platform-specific setup, domain verification, and NFC integration - Expanded push notifications docs with FCM implementation, platform-specific configurations, and data payload handling - Added database seeding section explaining how to use migrations for initial data setup - Updated various documentation files with improved clarity and additional configuration examples - Fixed broken links and improved navigation structure
1 parent 1c0ad47 commit 033fd97

File tree

9 files changed

+578
-549
lines changed

9 files changed

+578
-549
lines changed

resources/views/docs/mobile/1/concepts/databases.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,58 @@ upon foreign key constraints, [you need to enable SQLite support for them](https
2727
**It's important to test your migrations on prod builds before releasing updates!** You don't want to accidentally
2828
delete your user's data when they update your app.
2929

30+
## Seeding Data with Migrations
31+
32+
Migrations are the perfect mechanism for seeding data in mobile applications. They provide the natural behavior you want for data seeding:
33+
34+
- **Run once**: Each migration runs exactly once per device
35+
- **Tracked**: Laravel tracks which migrations have been executed
36+
- **Versioned**: New app versions can include new data seeding migrations
37+
- **Reversible**: You can create migrations to remove or update seed data
38+
39+
### Creating Seed Migrations
40+
41+
Create dedicated migrations for seeding data:
42+
43+
```bash
44+
php artisan make:migration seed_default_categories
45+
php artisan make:migration seed_app_settings
46+
php artisan make:migration seed_initial_user_data
47+
```
48+
49+
### Example: Seeding Default Categories
50+
51+
```php
52+
use Illuminate\Database\Migrations\Migration;
53+
use Illuminate\Support\Facades\DB;
54+
55+
return new class extends Migration
56+
{
57+
public function up()
58+
{
59+
DB::table('categories')->insert([
60+
['name' => 'Work', 'color' => '#3B82F6'],
61+
['name' => 'Personal', 'color' => '#10B981'],
62+
]);
63+
}
64+
65+
public function down()
66+
{
67+
// Rollback/fresh migrations never run
68+
}
69+
};
70+
```
71+
72+
### Best Practices for Seed Migrations
73+
74+
1. **Use specific timestamps**: Name migrations with dates to ensure proper ordering
75+
2. **Check before inserting**: Prevent duplicate data with updateOrCreate() or firstOrCreate()
76+
3. **Handle conflicts gracefully**: Check if data already exists before seeding
77+
4. **Use realistic data**: Seed with data that matches your production environment
78+
5. **Test thoroughly**: Verify seed migrations work on fresh installs and updates
79+
80+
This approach ensures your mobile app has the initial data it needs while maintaining consistency across different app versions and user devices.
81+
3082
## Things to note
3183

3284
- As your app is installed on a separate device, you do not have remote access to the database.

resources/views/docs/mobile/1/concepts/deep-links.md

Lines changed: 152 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ There are two types of link integrations you can configure:
1212
- **Deep Links** (myapp://some/path)
1313
- **Universal Links (iOS)** and **App Links (Android)** (https://example.net/some/path)
1414

15-
Each method has its use case, and NativePHP allows you to configure and handle both easily.
15+
Each method has its use case, and NativePHP handles all the platform-specific configuration automatically when you provide the proper environment variables.
1616

1717
---
1818

@@ -26,7 +26,6 @@ For example:
2626
myapp://profile/123
2727
```
2828

29-
3029
When a user taps a deep link, the mobile operating system detects the custom scheme and opens your app directly.
3130

3231
### Configuration
@@ -43,6 +42,12 @@ NATIVEPHP_DEEPLINK_SCHEME=myapp
4342
NATIVEPHP_DEEPLINK_HOST=open
4443
```
4544

45+
### Platform Behavior
46+
47+
- **iOS**: Deep links work immediately after installation
48+
- **Android**: Deep links work immediately after installation
49+
- **Both**: Apps will open directly when deep links are tapped
50+
4651
## Universal Links (iOS) and App Links (Android)
4752

4853
Universal Links and App Links allow real HTTPS URLs to open your app instead of a web browser, if the app is installed.
@@ -52,21 +57,25 @@ For example:
5257
https://example.net/property/456
5358
```
5459

60+
### User Experience
61+
5562
When a user taps this link:
5663

57-
- If your app is installed, it opens directly into the app.
58-
- If not, it opens normally in the browser.
64+
- **If your app is installed**: It opens directly into the app
65+
- **If not installed**: It opens normally in the browser
66+
- **Seamless fallback**: No broken experience for users without the app
5967

6068
This provides a seamless user experience without needing a custom scheme.
6169

6270
### 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.
6871

69-
NativePHP for Mobile handles all of this for you.
72+
1. You must prove to iOS and Android that you own the domain by hosting special files:
73+
- `.well-known/apple-app-site-association` (for iOS)
74+
- `.well-known/assetlinks.json` (for Android)
75+
2. The mobile OS reads these files to verify the link association
76+
3. Once verified, tapping a real URL will open your app instead of Safari or Chrome
77+
78+
**NativePHP handles all the technical setup automatically** - you just need to host the verification files and configure your domain.
7079

7180
### Configuration
7281

@@ -80,6 +89,87 @@ These are configured in your .env:
8089
NATIVEPHP_DEEPLINK_HOST=example.net
8190
```
8291

92+
#### Complete Configuration Example
93+
94+
```dotenv
95+
# For both deep links and universal/app links
96+
NATIVEPHP_DEEPLINK_SCHEME=myapp
97+
NATIVEPHP_DEEPLINK_HOST=example.net
98+
99+
# Your app will respond to:
100+
# myapp://profile/123 (deep link)
101+
# https://example.net/profile/123 (universal/app link)
102+
```
103+
104+
## Domain Verification
105+
106+
### Required Files
107+
108+
The app stores generate the content for these files, but you must host them on your domain:
109+
110+
#### iOS - `.well-known/apple-app-site-association`
111+
112+
```json
113+
{
114+
"applinks": {
115+
"details": [
116+
{
117+
"appIDs": ["TEAM_ID.com.yourcompany.yourapp"],
118+
"components": [
119+
{
120+
"*": "*"
121+
}
122+
]
123+
}
124+
]
125+
}
126+
}
127+
```
128+
129+
#### Android - `.well-known/assetlinks.json`
130+
131+
```json
132+
[{
133+
"relation": ["delegate_permission/common.handle_all_urls"],
134+
"target": {
135+
"namespace": "android_app",
136+
"package_name": "com.yourcompany.yourapp",
137+
"sha256_cert_fingerprints": ["SHA256_FINGERPRINT"]
138+
}
139+
}]
140+
```
141+
142+
### Verification Process
143+
144+
1. **iOS**: Apple's servers periodically check the `apple-app-site-association` file
145+
2. **Android**: Google Play Services verifies the `assetlinks.json` file
146+
3. **Both**: Files must be accessible via HTTPS without redirects
147+
4. **Content-Type**: Serve files as `application/json`
148+
149+
### Automatic Configuration
150+
151+
NativePHP automatically:
152+
- Configures iOS `associatedDomains` in your app
153+
- Sets up Android `intentFilters` for your domain
154+
- Generates the correct fingerprints and app IDs
155+
- Handles platform-specific URL routing
156+
157+
## Platform-Specific Behavior
158+
159+
### iOS Universal Links
160+
161+
- **Immediate**: Work as soon as the app is installed
162+
- **Smart Banner**: iOS can display an install banner if app isn't installed
163+
- **Fallback**: Opens in Safari if app isn't installed
164+
- **Cross-app**: Work from any app, not just Safari
165+
166+
### Android App Links
167+
168+
- **Verification**: Requires domain verification before working
169+
- **Default**: Can be set as default handler for domain links
170+
- **Fallback**: Opens in Chrome if app isn't installed
171+
- **Intent**: Uses Android's Intent system for routing
172+
83173
## Handling Universal/App Links
84174

85175
Once you've configured your deep link settings, you can handle the link in your app.
@@ -93,16 +183,67 @@ https://example.net/profile/123
93183
```php
94184
Route::get('/profile/{id}', function ($id) {
95185
// Handle the deep link
186+
// This works for both deep links and universal/app links
96187
});
97188
```
98189

190+
## Testing and Development
191+
192+
### Testing Limitations
193+
194+
- **Development builds**: Universal/App Links may not work in development
195+
- **Production required**: Full testing requires production builds and domain verification
196+
- **Simulator**: iOS Simulator may not handle Universal Links correctly
197+
198+
### Best Practices
199+
200+
1. **Test both link types** - Ensure deep links and universal/app links work
201+
2. **Verify domain files** - Check that .well-known files are accessible
202+
3. **Production testing** - Test universal/app links with production builds
203+
4. **Fallback handling** - Ensure your website handles users without the app
204+
5. **Analytics tracking** - Monitor which link types are most effective
205+
99206
## NFC
207+
100208
NFC is a technology that allows you to read and write NFC tags.
101209

102210
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.
211+
You can use a tool like [NFC Tools](https://www.wakdev.com/en/) to write NFC tags.
104212

105213
Set the url to a Universal/App Link and the tag will be written to the NFC tag.
106214
"Bumping" the tag will open the app.
107215

216+
### NFC Configuration
217+
218+
NFC tags work best with Universal/App Links because:
219+
- They provide fallback to website if app isn't installed
220+
- They work across different devices and platforms
221+
- They provide a better user experience than custom schemes
222+
223+
```bash
224+
# Write this URL to an NFC tag
225+
https://example.net/product/456
226+
227+
# When "bumped":
228+
# - Opens your app if installed
229+
# - Opens website if not installed
230+
```
231+
232+
## Troubleshooting
233+
234+
### Common Issues
235+
236+
1. **Universal Links not working**: Check domain verification files
237+
2. **Deep links not opening**: Verify URL scheme configuration
238+
3. **Wrong app opening**: Check for conflicting URL schemes
239+
4. **iOS Smart Banner**: Ensure proper app store metadata
240+
241+
### Debug Steps
242+
243+
1. **Verify .env configuration** - Check scheme and host values
244+
2. **Test deep links first** - Easier to debug than universal links
245+
3. **Check domain files** - Ensure .well-known files are accessible
246+
4. **Use production builds** - Development builds may not work correctly
247+
5. **Monitor app logs** - Check for link handling errors
108248

249+
Remember that NativePHP handles all the complex platform-specific setup automatically - you just need to configure your domain and environment variables correctly.

0 commit comments

Comments
 (0)