mr-swapan/applinks 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mr-swapan/applinks

Composer 安装命令:

composer require mr-swapan/applinks

包简介

Redirect to mobile app with deeplink URL.

README 文档

README

Redirect users to your mobile app using deep links, with safe fallbacks to Play Store / App Store or a web URL. Includes endpoints for Android Digital Asset Links and Apple App Site Association.

Requirements

  • PHP >= 8.0
  • Laravel 9.x / 10.x / 11.x / 12.x

Install

composer require mr-swapan/applinks

The service provider is auto-discovered by Laravel.

Publish config & migrations

php artisan vendor:publish --tag=applinks-config
php artisan vendor:publish --tag=applinks-migrations
php artisan migrate

Configuration

This package reads configuration from config/applinks.php (and the corresponding .env variables).

Core

  • APPLINKS_PREFIX (default: applinks/*)
  • APPLINKS_WEB (default: true)
  • APPLINKS_WEB_URL (default: empty; falls back to your app URL)
  • APPLINKS_DOMAIN (optional; reserved for your associated domain value)

Android

  • APPLINKS_ANDROID (default: true)
  • ANDROID_PACKAGE (example: com.example.app)
  • ANDROID_SHA256_CERT_FINGERPRINT (your app signing SHA-256 fingerprint)
  • ANDROID_PLAYSTORE_URL (example: market://details?id=com.example.app)

iOS

  • APPLINKS_IOS (default: true)
  • IOS_TEAM_ID (your Apple Team ID)
  • IOS_PACKAGE (your app bundle id)
  • IOS_APP_CUSTOM_LINK (example: com.example.app://applinks)
  • IOS_APPSTORE_URL (your App Store URL)

What routes does it add?

Routes are loaded from routes/web.php:

  • /.well-known/assetlinks.json and /assetlinks.json
  • /.well-known/apple-app-site-association and /apple-app-site-association
  • /applinks/{any?} (main redirect endpoint)
  • /applinks_save_device_info (internal helper)
  • /get_app_link_parameters (returns latest captured query params)
  • /js_editor (simple JS eval page; do not expose publicly)

Creating an applinks URL

The package registers a singleton named applinks (class: MrSwapan\Applinks\Services\ApplinksService).

Example (controller, job, etc.):

$url = app('applinks')->create([
    'campaign' => 'summer',
    'user_id' => 123,
], webUrl: 'https://example.com/fallback');

This generates a URL like:

https://your-domain.test/applinks?campaign=summer&user_id=123&web_url=https%3A%2F%2Fexample.com%2Ffallback

When a user opens that link:

  • Android: redirects to ANDROID_PLAYSTORE_URL and appends &referrer=<id> (where <id> is stored in applinks_data)
  • iOS: tries to open IOS_APP_CUSTOM_LINK with the same query params; after ~30 seconds it falls back to IOS_APPSTORE_URL
  • Other devices: redirects to web_url query param, or APPLINKS_WEB_URL, or your app URL

App association files

Android (Digital Asset Links)

Open /.well-known/assetlinks.json on your domain and verify it returns your:

  • ANDROID_PACKAGE
  • ANDROID_SHA256_CERT_FINGERPRINT

Android app configuration (required)

  1. Add an intent-filter for App Links (Android 6.0+).

In your AndroidManifest.xml (inside the Activity you want to open):

<activity android:name=".MainActivity">
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <!-- Use your real domain -->
        <data
            android:scheme="https"
            android:host="your-domain.com"
            android:pathPrefix="/applinks" />
    </intent-filter>
</activity>

Notes:

  • android:autoVerify="true" asks Android to verify the domain ownership using /.well-known/assetlinks.json.
  • android:pathPrefix="/applinks" should match your redirect path (default is /applinks/...).
  1. Get your signing certificate SHA-256 fingerprint and set it as ANDROID_SHA256_CERT_FINGERPRINT.

Common ways to obtain the SHA-256:

  • From Play Console (App Integrity / App signing)
  • From your keystore using keytool (debug or release keystore)
  1. Ensure HTTPS is used for your domain and that /.well-known/assetlinks.json is reachable publicly.

  2. Handle incoming links in your app.

When the app is opened by an App Link, it receives the URL via the Activity intent data. Parse the query string to get the parameters you attached (e.g. campaign, user_id, etc.).

iOS (Apple App Site Association)

Open /.well-known/apple-app-site-association and verify it returns:

  • IOS_TEAM_ID.IOS_PACKAGE
  • an applinks component pointing to your APPLINKS_PREFIX

iOS app configuration (required)

  1. Enable Associated Domains capability in Xcode.

In your app target:

  • Signing & Capabilities → + CapabilityAssociated Domains
  1. Add your applinks domain entry:

Add an entry like:

  • applinks:your-domain.com
  1. Ensure apple-app-site-association is served correctly.

This package provides:

  • /.well-known/apple-app-site-association
  • /apple-app-site-association

Notes:

  • The response must be served over HTTPS.
  • Apple expects no redirects for the /.well-known/... path.
  1. Handle Universal Links in the app.

Implement handling for the incoming universal link URL and parse the query parameters you attached.

  1. iOS fallback behavior in this package

If the request is detected as iOS, this package returns a small HTML page that:

  • Attempts to open IOS_APP_CUSTOM_LINK with the same query string
  • After ~30 seconds falls back to IOS_APPSTORE_URL

Set these values:

  • IOS_APP_CUSTOM_LINK (your app’s custom URL scheme link, example: com.example.app://applinks)
  • IOS_APPSTORE_URL (your App Store page URL)

License

MIT

mr-swapan/applinks 适用场景与选型建议

mr-swapan/applinks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 56 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mr-swapan/applinks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mr-swapan/applinks 我们能提供哪些服务?
定制开发 / 二次开发

基于 mr-swapan/applinks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 56
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 50
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-12