Skip to content
New issue

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

Not able to display WalletConnect FCM push notifications from background mode on Android #5181

Open
vaniyokk opened this issue Jul 12, 2024 · 1 comment
Labels
type: bug Something isn't working

Comments

@vaniyokk
Copy link

vaniyokk commented Jul 12, 2024

I was able to set up and receive notifications using WalletConnect cloud, FCM and react-native-firebase + Notifee.
Notification is displaying when app is not started (killed);

However, It's not possible to display data-only background notification in Android 12+ according known issue with background notifications handling on Android (Well described here: invertase/notifee#830 (comment), see whole thread)

It's because WalletConnect notifications are data-only (using data instead of notification property), and the system just ignores them in background state.

Is there any way to force display this kind of notifications? Notification received in background shows only when I open app (move it to foreground)

Here is my code for displaying notifications. I believe this is not an issue with web3wallet itself, but, seems like there is no possibility to properly handle data-only messages to notify user when app is in background but not killed.

await web3wallet.registerDeviceToken({
    token: await messaging().getToken(),
    clientId: await web3wallet.core.crypto.getClientId(),
    notificationType: "fcm",
    enableEncrypted: true
  });
    
    
...

// Create a channel (required for Android)
const channelId = await notifee.createChannel({
  id: "wallet-connect",
  name: "WalletConnect Notifications",
  importance: AndroidImportance.HIGH
});

try {
  // Display a notification
  await notifee.displayNotification({
    title: "Wallet Action Required",
    body: "Tap notification to open app and perform action on WalletConnect request",
    android: {
      importance: AndroidImportance.HIGH,
      channelId,
      smallIcon: "ic_small_icon",
      color: "#22C55E",
      // pressAction is needed if you want the notification to open the app when pressed
      pressAction: {
        id: "default"
      }
    }
  });
} catch (e) {
  // eslint-disable-next-line no-console
  console.log(e);
}

Also, here is my message I receive in background and which I can't display to user. Shouldn't it contain
"priority": "high", "contentAvailable": true fields as per https://rnfirebase.io/messaging/usage#data-only-messages?

{
"sentTime":1720796459112,
"data":{
  "message":"AMsv4PoyASwWoh/7IWybkGhbfd9ab1UW4RtlBG5vNtsOCDq5e5Z/RUClsNE0GTJ7FBMzB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P/Il47Ic+b6HaQ+B9yFkdLwzD/7/Ek9vSuKe15ca+qK2E9RK/xbDU5937gdMGtILp+v7+VwA4R5nvwzTQ7hRXiZZPAoh/mvA6asMfYQwCb8/pUNSuVJ39nwwQndinvbIXBjKYmz9L2B8S9vy8J2y/N+rkEB8SuJAOn3aR/mGoapCFv2UMffcdBlJdwAL18Xzs7/3liEt+lKERUypdMlQyMHhir1b8oyUou1q3TSFeXlSGTM0MIZyfHc/8jORA37t31LB7cmTrpN8eDPdl19K2aSYGTkU5wj9+5H8HP/J784scsTrp9Nl+qel0RcA8M3xE3rxtc2Bu7TLGvWcY62cRoKFjb1ncZw8UDmvScoapclRNqEdINshAT/JVA/H9ughYbeu8olK8GXKJQiDSILNzTeTjdJJSUgw+Eo+tvrp28vmicVT8cdNTgcF9WKkHGBxDoDwE55D+1XIot/55iLEB3dNQ37ROT2ED5KGYFgsLzKhLKqeui",
  "topic":"ac94b1f8926ffd4121f920251f482cbd526a02e7fab3559e70327d5af940f26d",
  "tag":"1108"
},
"messageId":"0:1720796459128835%72925286f9fd7ecd",
"ttl":2419200,
"from":"830012384765"
}

SDK Version (if relevant)

  • Client: @walletconnect/web3wallet
  • Version: 1.12.3

Expected behavior
There should be a way to receive and notify user about WalletConnect request if wallet app is hidden (in background)

Smartphone (please complete the following information):

  • Device: Poco F2 Pro
  • OS: Android 14 (CrDroid)
@vaniyokk vaniyokk added the type: bug Something isn't working label Jul 12, 2024
Copy link

linear bot commented Jul 12, 2024

@vaniyokk vaniyokk changed the title Not able to display FCM push notifications from background mode on Android Not able to display WalletConnect FCM push notifications from background mode on Android Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant