mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-12-22 08:25:53 -05:00
add example of rememberLauncherForActivityResult
This commit is contained in:
parent
6b26ebe6c5
commit
a2aaa3c00b
24
100.md
24
100.md
|
@ -40,6 +40,24 @@ fun isExternalSignerInstalled(context: Context): Boolean {
|
|||
|
||||
To get the result back from the Signer Application you should use `registerForActivityResult` or `rememberLauncherForActivityResult` in Kotlin. If you are using another framework check the documentation of your framework or a third party library to get the result.
|
||||
|
||||
```kotlin
|
||||
val launcher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.StartActivityForResult(),
|
||||
onResult = { result ->
|
||||
if (result.resultCode != Activity.RESULT_OK) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
"Sign request rejected",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
val signature = activityResult.data?.getStringExtra("signature")
|
||||
// Do something with signature ...
|
||||
}
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
Create the Intent using the **nostrsigner** scheme:
|
||||
|
||||
```kotlin
|
||||
|
@ -52,6 +70,12 @@ Set the Signer package name:
|
|||
intent.`package` = "com.example.signer"
|
||||
```
|
||||
|
||||
Send the Intent:
|
||||
|
||||
```kotlin
|
||||
launcher.launch(intent)
|
||||
```
|
||||
|
||||
### Methods
|
||||
|
||||
- **get_public_key**
|
||||
|
|
Loading…
Reference in New Issue
Block a user