Deep Linking & Universal Links — Mobile

Deep Linking di Mobile App Deep linking memungkinkan URL membuka screen spesifik di app kamu — bukan hanya home screen. Ini penting untuk sharing content…

Deep Linking di Mobile App

Deep linking memungkinkan URL membuka screen spesifik di app kamu — bukan hanya home screen. Ini penting untuk sharing content, email marketing, dan navigasi dari web ke app.

Tipe Deep Links

Setup di Expo

// app.json
{
  "expo": {
    "scheme": "myapp",
    "ios": {
      "associatedDomains": ["applinks:myapp.com"]
    },
    "android": {
      "intentFilters": [
        {
          "action": "VIEW",
          "autoVerify": true,
          "data": [
            {
              "scheme": "https",
              "host": "myapp.com",
              "pathPrefix": "/"
            }
          ],
          "category": ["BROWSABLE", "DEFAULT"]
        }
      ]
    }
  }
}

Handle Deep Links dengan Expo Router

// Expo Router otomatis handle deep links!
// URL myapp://profile/42 → app/profile/[id].tsx

// app/profile/[id].tsx
import { useLocalSearchParams } from 'expo-router';

export default function ProfileScreen() {
  const { id } = useLocalSearchParams();
  // id = '42' dari deep link
  return <Text>Profile {id}</Text>;
}

// Handle link saat app sudah terbuka
import { useURL } from 'expo-linking';

function App() {
  const url = useURL();

  useEffect(() => {
    if (url) {
      // Parse dan navigate
      const { path, queryParams } = Linking.parse(url);
      router.push(path);
    }
  }, [url]);
}

Universal Links Verification

// Untuk Universal Links, hosting file verification:

// iOS: https://myapp.com/.well-known/apple-app-site-association
{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "TEAM_ID.com.myapp.app",
        "paths": ["/profile/*", "/post/*"]
      }
    ]
  }
}

// Android: https://myapp.com/.well-known/assetlinks.json
[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.myapp.app",
    "sha256_cert_fingerprints": ["AA:BB:CC:..."]
  }
}]

Use Cases

Yang akan kamu pelajari