android - How to fix deep linking in iOS when the application has not installed in the device? - TagMerge
3How to fix deep linking in iOS when the application has not installed in the device?How to fix deep linking in iOS when the application has not installed in the device?

How to fix deep linking in iOS when the application has not installed in the device?

Asked 5 months ago
4
3 answers

Basically what happens is that you try to deep link using the URI scheme provided above (my.special.scheme://other/parameters/here) and it fails since the app is not installed. In that case you cannot catch the failure and redirect the user elsewhere.

You can set your BE to return something similar to this:

window.location.href = "my.special.scheme://other/parameters/here";
setTimeout(function () {
    window.location.href = ...store_link_for_your_app..;
}, 1000);

That way, if deep link fails, after 1s you'll get a redirect.

Important notes:

Source: link

1

Hope help anyone:

var deeplinkUrl = `yourscheme://myurl?param1=x&param2=y`;
//variable will check app installed or not
var change = false;
setTimeout(() => {
  if (!change) {
    var redirectUrl = "your store url";
    window.location = redirectUrl;
  }
}, 3000);
window.location = deeplinkUrl;
//handle event to check app installed or not
window.onblur = function () {
    change = true;
};
window.onfocus = function(){
    change = false;
}

Source: link

0

Deep linking into an android app using the Router widget throws an error:
E/AndroidRuntime( 8741): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference
Create a new Flutter project with main.dart replaced with the contents of this sample Update main/AndroidManifest.xml with this configuration inside the <activity android:name=".MainActivity"> XML node:
<!-- Deep linking -->
            <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
            <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" />
                <data android:scheme="http" android:host="flutterbooksample.com" />
                <data android:scheme="https" />
            </intent-filter>
Run this the app Run this command to trigger a deep link into the app:
adb shell am start -a android.intent.action.VIEW \
    -c android.intent.category.BROWSABLE \
    -d "http://flutterbooksample.com/book/1"
Logs
D/AndroidRuntime( 8741): Shutting down VM
E/AndroidRuntime( 8741): FATAL EXCEPTION: main
E/AndroidRuntime( 8741): Process: com.example.router_app, PID: 8741
E/AndroidRuntime( 8741): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference
E/AndroidRuntime( 8741): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.maybeGetInitialRouteFromIntent(FlutterActivityAndFragmentDelegate.java:403)
E/AndroidRuntime( 8741): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onNewIntent(FlutterActivityAndFragmentDelegate.java:648)
E/AndroidRuntime( 8741): 	at io.flutter.embedding.android.FlutterActivity.onNewIntent(FlutterActivity.java:625)
E/AndroidRuntime( 8741): 	at android.app.Activity.performNewIntent(Activity.java:8015)
E/AndroidRuntime( 8741): 	at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1409)
E/AndroidRuntime( 8741): 	at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1422)
E/AndroidRuntime( 8741): 	at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:3664)
E/AndroidRuntime( 8741): 	at android.app.ActivityThread.handleNewIntent(ActivityThread.java:3676)
E/AndroidRuntime( 8741): 	at android.app.servertransaction.NewIntentItem.execute(NewIntentItem.java:53)
E/AndroidRuntime( 8741): 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime( 8741): 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime( 8741): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
E/AndroidRuntime( 8741): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 8741): 	at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime( 8741): 	at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime( 8741): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 8741): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime( 8741): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/Process ( 8741): Sending signal. PID: 8741 SIG: 9
Lost connection to device.
D/AndroidRuntime( 8741): Shutting down VM E/AndroidRuntime( 8741): FATAL EXCEPTION: main E/AndroidRuntime( 8741): Process: com.example.router_app, PID: 8741 E/AndroidRuntime( 8741): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference E/AndroidRuntime( 8741): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.maybeGetInitialRouteFromIntent(FlutterActivityAndFragmentDelegate.java:403) E/AndroidRuntime( 8741): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onNewIntent(FlutterActivityAndFragmentDelegate.java:648) E/AndroidRuntime( 8741): at io.flutter.embedding.android.FlutterActivity.onNewIntent(FlutterActivity.java:625) E/AndroidRuntime( 8741): at android.app.Activity.performNewIntent(Activity.java:8015) E/AndroidRuntime( 8741): at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1409) E/AndroidRuntime( 8741): at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1422) E/AndroidRuntime( 8741): at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:3664) E/AndroidRuntime( 8741): at android.app.ActivityThread.handleNewIntent(ActivityThread.java:3676) E/AndroidRuntime( 8741): at android.app.servertransaction.NewIntentItem.execute(NewIntentItem.java:53) E/AndroidRuntime( 8741): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) E/AndroidRuntime( 8741): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) E/AndroidRuntime( 8741): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) E/AndroidRuntime( 8741): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime( 8741): at android.os.Looper.loop(Looper.java:223) E/AndroidRuntime( 8741): at android.app.ActivityThread.main(ActivityThread.java:7656) E/AndroidRuntime( 8741): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 8741): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) E/AndroidRuntime( 8741): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) I/Process ( 8741): Sending signal. PID: 8741 SIG: 9 Lost connection to device.
flutter doctor -v                                 
[✓] Flutter (Channel master, 1.26.0-18.0.pre.133, on macOS 11.1 20C69 darwin-x64, locale en)
    • Flutter version 1.26.0-18.0.pre.133 at /Users/ryjohn/code/sdks/flutter
    • Framework revision 5b6444f317 (64 minutes ago), 2021-02-02 09:34:01 -0800
    • Engine revision 8a01ce59bf
    • Dart version 2.12.0 (build 2.12.0-281.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/ryjohn/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 53.0.5
    • Dart plugin version 203.6912

[✓] Connected device (3 available)
    • sdk gphone x86 arm (mobile) • emulator-5554                        • android-x86    • Android 11
      (API 30) (emulator)
    • iPhone 12 Pro Max (mobile)  • AE85D456-A89C-4104-B6F0-F68F35A93165 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • Chrome (web)                • chrome                               • web-javascript • Google
      Chrome 88.0.4324.96

• No issues found!

Source: link

Recent Questions on android

    Programming Languages