JF-Mechs
JF-Mechs

Reputation: 1081

Cordova: Edit Info.plist from plugin.xml

I’m currently developing a website and need to add a button that links to my mobile app. I’ve implemented a deep link (or universal link) to redirect users directly to the app’s dashboard. If the app isn’t installed, the fallback should redirect to the appropriate app store.

Here’s the currently implemented code:

window.location.href = "com.jfmech.myapp1://myapp1_main_module/dashboard".

setTimeout(function(){
   window.location.href = GetStoreLinkByOS();
}, 2000);

This works perfectly on Android but not on iOS.

I’ve read that I need to register the URL scheme or universal link in the Info.plist file, and here’s what I’ve added so far:

<platform name="ios">
    <config-file target="*-Info.plist" parent="CFBundleURLTypes">
        <array>
            <dict>
                <key>CFBundleURLName</key>
                <string>com.jfmech.myapp1</string> <!-- Replace with your app's identifier -->
                <key>CFBundleURLSchemes</key>
                <array>
                    <string>com.jfmech.myapp1</string>
                </array>
            </dict>
        </array>
    </config-file>
</platform>

Despite this, the fallback logic always kicks in on iOS, redirecting users to the store instead of opening the app even if its already installed.

What am I missing? Any guidance would be appreciated.

Update:

I have also found out about setting up an AASA file and have successfully hosted it.

AASA validation via branch.io

Then updated the xml to add the key for the AASA

<config-file target="*-Info.plist" parent="com.apple.developer.associated-domains">
    <array>
        <string>applinks:mydomain.com</string>
    </array>
</config-file>

Still, did not get the job done.

Upvotes: 1

Views: 83

Answers (1)

JF-Mechs
JF-Mechs

Reputation: 1081

I’ve updated my JS code to:

window.open("<myappid>://myapp1_main_module/dashboard", "_system")

This works, but it’s inconsistent across devices and causes significant issues when the webpage is opened in a browser with pop-up blocker enabled.

This might not be related to the plist, and it doesn’t solve my issue or answer my question, but I’m sharing it in case anyone else considers this as a temporary solution.

Upvotes: 1

Related Questions