aboutsummaryrefslogtreecommitdiffstats
path: root/android/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'android/app/src/main')
-rw-r--r--android/app/src/main/java/io/coinos/app/PushReceiver.java28
-rw-r--r--android/app/src/main/res/values/strings.xml2
2 files changed, 19 insertions, 11 deletions
diff --git a/android/app/src/main/java/io/coinos/app/PushReceiver.java b/android/app/src/main/java/io/coinos/app/PushReceiver.java
index ce3e3f0..b14de53 100644
--- a/android/app/src/main/java/io/coinos/app/PushReceiver.java
+++ b/android/app/src/main/java/io/coinos/app/PushReceiver.java
@@ -49,14 +49,7 @@ public class PushReceiver extends BroadcastReceiver {
case Push.ACTION_MESSAGE: {
byte[] bytes = intent.getByteArrayExtra(Push.EXTRA_BYTES_MESSAGE);
String body = bytes != null ? new String(bytes) : intent.getStringExtra(Push.EXTRA_MESSAGE);
- // On the WebView build the wallet lives in THIS app's storage, so it
- // can be woken and told to deal with whatever arrived. On the TWA
- // build the wallet is Chrome's and out of reach, so the notification
- // is the whole of what we can do.
- boolean woke = Wake.start(context, body);
- // A payment or a message is news whether or not we handled it; a
- // wallet-connect request is not, unless nobody is going to answer it.
- if (!woke || !isSilent(body)) notify(context, body);
+ onPush(context, body);
Push.ack(context, intent.getStringExtra(Push.EXTRA_ID));
break;
}
@@ -65,8 +58,23 @@ public class PushReceiver extends BroadcastReceiver {
}
}
+ /**
+ * A push, however it came (a UnifiedPush distributor, or Firebase in the
+ * fcm build — FcmService): the same JSON either way.
+ */
+ static void onPush(Context context, String body) {
+ // On the WebView build the wallet lives in THIS app's storage, so it
+ // can be woken and told to deal with whatever arrived. On the TWA
+ // build the wallet is Chrome's and out of reach, so the notification
+ // is the whole of what we can do.
+ boolean woke = Wake.start(context, body);
+ // A payment or a message is news whether or not we handled it; a
+ // wallet-connect request is not, unless nobody is going to answer it.
+ if (!woke || !isSilent(body)) notify(context, body);
+ }
+
/** Requests the woken wallet answers by itself need no notification. */
- private boolean isSilent(String payload) {
+ private static boolean isSilent(String payload) {
try {
JSONObject j = new JSONObject(payload == null ? "{}" : payload);
String reason = j.optString("reason", j.optString("type", ""));
@@ -79,7 +87,7 @@ public class PushReceiver extends BroadcastReceiver {
* describes; anything we don't recognise still gets a notification, because
* silence is the one answer that's always wrong here.
*/
- private void notify(Context c, String payload) {
+ private static void notify(Context c, String payload) {
String title = c.getString(R.string.app_name);
String text = c.getString(R.string.push_generic);
String deepLink = null;
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index 8132a82..77fa055 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -12,7 +12,7 @@
<!-- must match the site's /.well-known/assetlinks.json for URL-bar-less TWA -->
<string name="asset_statements">
[{
- \"relation\": [\"delegate_permission/common.handle_all_urls\"],
+ \"relation\": [\"delegate_permission/common.handle_all_urls\", \"delegate_permission/common.get_login_creds\"],
\"target\": { \"namespace\": \"web\", \"site\": \"https://v3.coinos.io\" }
}]
</string>