Mobile App Integration
Integrate Loyalteez rewards into your iOS, Android, or React Native mobile app using our REST API.
Overviewβ
Mobile apps integrate via direct HTTP API calls to our Cloudflare Workers. This approach works for all mobile platformsβno native SDK required.
Mobile Architectureβ
Integration Optionsβ
1. React Native (Recommended)β
- Uses Expo or React Native CLI
- Privy SDK available
- Similar to web React integration
- See: React Native Guide
2. Native iOSβ
- Swift or Objective-C
- URLSession for API calls
- Privy iOS SDK
- See: iOS Guide
3. Native Androidβ
- Kotlin or Java
- Retrofit or OkHttp for API calls
- Privy Android SDK
- See: Android Guide
4. Flutterβ
- Dart language
- http package for API calls
- Custom Privy integration
- See: Flutter Guide
Key Differences from Webβ
| Feature | Web | Mobile |
|---|---|---|
| SDK | JavaScript CDN | Direct API calls |
| Authentication | Privy Web SDK | Privy Mobile SDK |
| Event Tracking | Auto-detection | Manual calls |
| Wallet | Browser extension | In-app wallet (Privy) |
| Push Notifications | Not available | Push for rewards |
| Offline | Limited | Queue events |
| Deep Linking | URLs | App scheme |
Core Integration Stepsβ
Step 1: Set Up Authenticationβ
Mobile apps use Privy Mobile SDK for authentication:
iOS: CocoaPods or SPM
Android: Gradle
React Native: npm package
Step 2: Track Events via APIβ
Make HTTP POST requests to track user actions:
POST https://api.loyalteez.app/loyalteez-api/manual-event
Content-Type: application/json
{
"event": "account_creation",
"email": "[email protected]",
"metadata": {
"platform": "mobile",
"os": "iOS"
}
}
Step 3: Enable Gasless Transactionsβ
For perk claims, use the Gas Relayer:
POST https://relayer.loyalteez.app/relay
Authorization: Bearer PRIVY_ACCESS_TOKEN
Content-Type: application/json
{
"to": "0x6ae30d6Dcf3e75456B6582b057f1Bf98A90F2CA0",
"data": "0x...",
"userAddress": "0x..."
}
Mobile-Specific Featuresβ
1. Push Notificationsβ
Notify users when they earn rewards:
// When LTZ distributed
{
"title": "You earned 100 LTZ!",
"body": "Complete your profile to earn more",
"data": {
"type": "reward",
"amount": 100,
"txHash": "0x..."
}
}
2. Deep Linkingβ
Link directly to wallet or perks:
loyalteez://wallet
loyalteez://perk/123
loyalteez://claim/456
3. Offline Event Queueingβ
Queue events when offline, sync when online:
// Pseudocode
if (isOnline) {
sendEvent(event);
} else {
queueEvent(event);
// Sync later when online
}
4. Biometric Authenticationβ
Use Face ID / Touch ID for secure transactions:
// iOS example
LocalAuthentication.authenticate() { success in
if success {
executeTransaction()
}
}
Common Use Casesβ
1. Social Appβ
- Track profile creation β 100 LTZ
- Track post creation β 10 LTZ
- Track friend referral β 500 LTZ
- Enable perk claims (premium features)
2. E-commerce Appβ
- Track account signup β 50 LTZ
- Track first purchase β 200 LTZ
- Track purchases β 1 LTZ per $1
- Enable perk redemption (discounts)
3. Gaming Appβ
- Track level completion β 25 LTZ
- Track daily login β 5 LTZ
- Track achievement β 50 LTZ
- Enable perk claims (power-ups)
4. Fitness Appβ
- Track workout completion β 20 LTZ
- Track goal achievement β 100 LTZ
- Track streak milestone β 50 LTZ
- Enable perk claims (premium features)
Best Practicesβ
β Do Thisβ
- Queue events offline - Don't lose data
- Add retry logic - Handle network failures
- Use Privy for wallets - No wallet complexity
- Show rewards in-app - "You earned X LTZ!"
- Add push notifications - Increase engagement
- Use deep linking - Easy navigation
- Cache wallet address - Reduce API calls
- Handle errors gracefully - Good UX
β Avoid Thisβ
- Don't spam events - Rate limits exist
- Don't expose API keys - Use environment variables
- Don't skip auth - Gas relayer requires Privy token
- Don't hardcode URLs - Use config files
- Don't ignore offline - Queue events
- Don't skip error handling - Apps crash
API Endpoints for Mobileβ
| Endpoint | Method | Purpose |
|---|---|---|
/loyalteez-api/manual-event | POST | Track user events |
/loyalteez-api/debug | GET | Health check |
/relay | POST | Gasless transactions |
Base URLs:
- Event Handler:
https://api.loyalteez.app - Gas Relayer:
https://relayer.loyalteez.app
Authentication Flowβ
Network Configurationβ
All mobile apps connect to Soneium Mainnet:
{
"chainId": 1868,
"rpcUrl": "https://rpc.soneium.org",
"blockExplorer": "https://soneium.blockscout.com",
"contracts": {
"loyalteez": "0x5242b6DB88A72752ac5a54cFe6A7DB8244d743c9",
"perkNFT": "0x6ae30d6Dcf3e75456B6582b057f1Bf98A90F2CA0",
"pointsSale": "0x5269B83F6A4E31bEdFDf5329DC052FBb661e3c72"
}
}
Testing Your Integrationβ
1. Test Event Trackingβ
# Use your mobile app or curl to test
curl -X POST https://api.loyalteez.app/loyalteez-api/manual-event \
-H "Content-Type: application/json" \
-d '{
"event": "test_mobile_event",
"email": "[email protected]",
"metadata": {
"platform": "mobile",
"os": "iOS",
"version": "1.0.0"
}
}'
2. Check Partner Portalβ
Go to partners.loyalteez.app/analytics to see:
- Events received
- LTZ distributed
- Active users
3. Test Gasless Transactionsβ
Make sure Privy authentication works and gas relayer accepts requests.
Performance Tipsβ
- Batch events - Send multiple events in one request (if supported)
- Cache aggressively - Wallet address, user data
- Use compression - gzip requests if possible
- Timeout wisely - 30s for events, 60s for transactions
- Monitor network - Detect offline early
Security Considerationsβ
- Store tokens securely - Use Keychain (iOS) / KeyStore (Android)
- Use HTTPS only - Never use HTTP
- Validate responses - Check server responses
- Rate limit locally - Don't spam your own app
- Obfuscate code - Protect API keys in prod builds
Supportβ
- Mobile Examples: See platform-specific guides
- API Reference: Event Handler API
- Gas Relayer: Gas Relayer API
- Email Support: [email protected]
Next Stepsβ
Choose your platform:
- π± React Native Guide - Cross-platform
- π iOS Guide - Native Swift
- π€ Android Guide - Native Kotlin
- π¨ Flutter Guide - Cross-platform
Recommended: Start with React Native for faster development across both platforms.