We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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) } } }
}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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() {
}
The text was updated successfully, but these errors were encountered: