-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #312 from WalletConnect/feature/link_mode
Link Mode
- Loading branch information
Showing
107 changed files
with
3,348 additions
and
1,400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
example/dapp/android/app/src/main/kotlin/com/example/dapp/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,65 @@ | ||
package com.example.dapp | ||
|
||
import io.flutter.embedding.android.FlutterActivity | ||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import androidx.annotation.NonNull | ||
|
||
import io.flutter.embedding.engine.FlutterEngine | ||
import io.flutter.plugin.common.EventChannel | ||
import io.flutter.plugin.common.MethodCall | ||
import io.flutter.plugin.common.MethodChannel | ||
|
||
class MainActivity: FlutterActivity() { | ||
private val eventsChannel = "com.walletconnect.flutterdapp/events" | ||
private val methodsChannel = "com.walletconnect.flutterdapp/methods" | ||
|
||
private var initialLink: String? = null | ||
private var linksReceiver: BroadcastReceiver? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
val intent: Intent? = intent | ||
initialLink = intent?.data?.toString() | ||
|
||
EventChannel(flutterEngine?.dartExecutor?.binaryMessenger, eventsChannel).setStreamHandler( | ||
object : EventChannel.StreamHandler { | ||
override fun onListen(args: Any?, events: EventChannel.EventSink) { | ||
linksReceiver = createChangeReceiver(events) | ||
} | ||
override fun onCancel(args: Any?) { | ||
linksReceiver = null | ||
} | ||
} | ||
) | ||
|
||
MethodChannel(flutterEngine!!.dartExecutor.binaryMessenger, methodsChannel).setMethodCallHandler { call, result -> | ||
if (call.method == "initialLink") { | ||
if (initialLink != null) { | ||
result.success(initialLink) | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun onNewIntent(intent: Intent) { | ||
super.onNewIntent(intent) | ||
if (intent.action === Intent.ACTION_VIEW) { | ||
linksReceiver?.onReceive(this.applicationContext, intent) | ||
} | ||
} | ||
|
||
fun createChangeReceiver(events: EventChannel.EventSink): BroadcastReceiver? { | ||
return object : BroadcastReceiver() { | ||
override fun onReceive(context: Context, intent: Intent) { | ||
val dataString = intent.dataString ?: | ||
events.error("UNAVAILABLE", "Link unavailable", null) | ||
events.success(dataString) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.developer.associated-domains</key> | ||
<array> | ||
<string>applinks:lab.web3modal.com</string> | ||
<string>applinks:dev.lab.web3modal.com</string> | ||
<string>applinks:web3modal-laboratory-git-chores-addedmore-3e0f2b-walletconnect1.vercel.app</string> | ||
</array> | ||
</dict> | ||
</plist> |
Oops, something went wrong.