Code Monkey home page Code Monkey logo

deep_links_flutter's Introduction

deep_links_flutter

The Flutter PoC for Deep Links

Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

deep_links_flutter's People

Contributors

aleksandr-denisov-epam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

deep_links_flutter's Issues

Everytime getting null on link click

in android on link click redirect to app, but on DeepLinkBloc everytime returns null

[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18362.592], locale en-US)
• Flutter version 1.12.13+hotfix.5 at F:\flutter_sdk\flutter
• Framework revision 27321ebbad (6 weeks ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at D:/adt-bundle-windows-x86-20130514/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = D:/adt-bundle-windows-x86-20130514/sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.

[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] Connected device (1 available)
• SM G615F • 4200169d96a47449 • android-arm • Android 8.1.0 (API 27)

• No issues found!

iOS example - initialLink

Hi - first, this article and the examples here were extremely helpful to me, thank you!

I think one small detail is missing on the iOS implementation. In the platform method channel handler, when the "initialLink" method is called - it is not returning any value.

The code in question is here https://github.com/DenisovAV/deep_links_flutter/blob/master/ios/Runner/AppDelegate.swift#L23

I believe what needs to happen, to handle deep links that launch the app, is to add this line in the didFinishLaunchingWithOptions function in AppDelegate, to capture any initial link url:

let initialLink = launchOptions?[.url] as? String

Then, inside the setMethodCallHandler, as long as it passes the existing guard statement (the "initialLink" method check), return a result with this initialLink value.

methodChannel?.setMethodCallHandler({ (call: FlutterMethodCall, result: FlutterResult) in
    guard call.method == "initialLink" else {
        result(FlutterMethodNotImplemented)
        return
    }

    result(initialLink)
})

App crashes after changing the mainactivity.kt

package dev.flutter.deep_links_flutter

import android.content.BroadcastReceiver
import android.os.Bundle
import android.content.Context
import android.content.Intent
import androidx.annotation.NonNull
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.EventChannel
import io.flutter.plugin.common.EventChannel.EventSink
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterActivity() {

private val CHANNEL = "poc.deeplink.flutter.dev/channel"
private val EVENTS = "poc.deeplink.flutter.dev/events"
private var startString: String? = null
private var linksReceiver: BroadcastReceiver? = null

override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
    GeneratedPluginRegistrant.registerWith(flutterEngine)

    MethodChannel(flutterEngine.dartExecutor, CHANNEL).setMethodCallHandler { call, result ->
        if (call.method == "initialLink") {
            if (startString != null) {
                result.success(startString)
            }
        }
    }

    EventChannel(flutterEngine.dartExecutor, EVENTS).setStreamHandler(
            object : EventChannel.StreamHandler {
                override fun onListen(args: Any?, events: EventSink) {
                    linksReceiver = createChangeReceiver(events)
                }

                override fun onCancel(args: Any?) {
                    linksReceiver = null
                }
            }
    )
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    val intent = getIntent()
    startString = intent.data?.toString()
}

override fun onNewIntent(intent: Intent) {
    super.onNewIntent(intent)
    if (intent.action === Intent.ACTION_VIEW) {
        linksReceiver?.onReceive(this.applicationContext, intent)
    }
}

fun createChangeReceiver(events: EventSink): BroadcastReceiver? {
    return object : BroadcastReceiver() {
        override fun onReceive(context: Context, intent: Intent) { // NOTE: assuming intent.getAction() is Intent.ACTION_VIEW
            val dataString = intent.dataString ?:
            events.error("UNAVAILABLE", "Link unavailable", null)
            events.success(dataString)
        }
    }
}

}

Redirect to deep link

I see that the deep link only works when I click on a button from the browser.
How do I handle a url redirect to a deep link?
My app does oauth authentication with the other app via service, in return it calls a url in the browser and then makes a redirect to a deep link, but android doesn't understand that it has to open the app.

error in flutter 2

Hello
I used your package regarding Deep Link

But after I updated the flutter version to 2, it didn't work anymore
Gives the following error
Thank you for your help

E/AndroidRuntime( 1866): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference
E/AndroidRuntime( 1866): at http://io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.maybeGetInitialRouteFromIntent(https://t.co/0EzqKy6ilp)
E/AndroidRuntime( 1866): at http://io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onNewIntent(https://t.co/PU3T7hi4Db)
E/AndroidRuntime( 1866): at http://io.flutter.embedding.android.FlutterActivity.onNewIntent(https://t.co/q8aTDqYPzl)
E/AndroidRuntime( 1866): at app-name.MainActivity.onNewIntent(MainActivity.kt:66)
E/AndroidRuntime( 1866): at http://android.app.Activity.performNewIntent(https://t.co/VnbS18Pdbx)

error: incompatible types: MainActivity cannot be converted to FlutterEngine

Running

  • flutter build apk

returns the following error:

\android\app\src\main\java\dev\flutter\deep_links_flutter\MainActivity.java:25: error: incompatible types: MainActivity cannot be converted to FlutterEngine
    GeneratedPluginRegistrant.registerWith(this);
                                           ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                       1,9s
Gradle task assembleRelease failed with exit code 1

Flutter doctor:

[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Versión 10.0.18363.592], locale es-BO)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[!] Android Studio (not installed)
[√] VS Code, 64-bit edition (version 1.41.1)
[!] Connected device

! Doctor found issues in 2 categories.

MissingPluginException

I/flutter ( 6794): The following MissingPluginException was thrown while activating platform stream on channel
I/flutter ( 6794): https.mydomain.com/events:
I/flutter ( 6794): MissingPluginException(No implementation found for method listen on channel
I/flutter ( 6794): https.mydomain.com/events)
I/flutter ( 6794):
I/flutter ( 6794): When the exception was thrown, this was the stack:
I/flutter ( 6794): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:7)
I/flutter ( 6794):
I/flutter ( 6794): #1 EventChannel.receiveBroadcastStream. (package:flutter/src/services/platform_channel.dart:545:9)
I/flutter ( 6794):
I/flutter ( 6794): ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.