cordova-plugin-firebase notifications working on Google Firebase console but not on API - api

Using the cordova-plugin-firebase plugin, I can only get device notifications via the Google Firebase console, and not through the server http API.
APP: cordova (6.4.0) default app, not changed, with plugin cordova-plugin-firebase (0.1.21) added.
Steps to reproduce
Download APP to device (android phone)
Start APP (seems like this is required to register this app with the phone)
Close APP
Send message from server through FCM http API
{ notification:
{ title: 'Notification Test',
body: 'Notification Test Body Text' },
to: '/topics/all',
priority: 'high' }
Device does not receive/show a notification was received.
Is there a bug in the server script?
No. If I replace cordova-plugin-firebase with cordova-plugin-fcm, then the device (and APP) receive notifications through the API just fine.
Why not just use cordova-plugin-fcm then?
cordova-plugin-fcm is not well maintained, and I would like to use the Analytics in cordova-plugin-firebase

Related

Will an Android app only receive push notifications is the app was downloaded from the Google Play Store? (React Native Expo)

I'm using Expo push notifications. Push notifications work fine in Expo Go and for apps on published to the Google Play store. But when I create an APK file and download it directly onto my Android phone, NOT through the Google Play store, the push notifications I send are not received.
Will push notifications only work for apps published to the Google Play store? Or is there a way to receive push notifications for apps downloaded directly onto an Android phone without being published to the Google Play store?
Depending on your android version and rom you have to open the app setting's (for me long press app icon).
Select settings
Choose notifications
Enable notification for this app
I forgot to import { Platform } from 'react-native'.
Also, I needed to upload Android server api key credentials which can be found in Firebase Console in your project settings under Cloud Messaging. Here is how to upload the server api key credentials in the terminal:
expo push:android:upload --api-key <your-token-here>
Documentation can be found here under "Uploading Server Credentials": https://docs.expo.dev/push-notifications/using-fcm/

react-native-firebase - Open app from Headless JS Service / Open app from received notification in background mode

I read
How to handle notification when app in background in Firebase
Open app on firebase notification received (FCM)
But these aren't the solution for react-native-firebase.
I'm using react-native-firebase to handle notifications. In foreground, everything works well. I stuck with background state.
I'm working on a chat project and making 1-to-1 call feature. I push data-notification to clients when they have a call. In iOS, I used CallKit when client received notification, and it worked fine. But in Android I have a problem:
I can show ConnectionService UI for a call, but can't connect to my web socket server because it runs on Headless JS service. So I tried to auto open the app. I want to show a call screen as Skype, and accept/deny the call. (Skype can launch the app when I have a call)
Summary, successful steps:
Receive call notification in foreground state and show calling screen.
Receive call notification in background/closed state and show calling screen on iOS.
Receive call notification in background/closed state on Android.
Stuck here:
Show calling screen in background/closed on Android ???
TL;DR - How to launch/run/open Android app from Headless JS Service?
I dig into react-native-firebase, it catches the notification on onMessageReceived and send notification message to Headless JS Service.
// If the app is in the background we send it to the Headless JS Service
Intent headlessIntent = new Intent(
this.getApplicationContext(),
RNFirebaseBackgroundMessagingService.class
);
headlessIntent.putExtra("message", message);
this
.getApplicationContext()
.startService(headlessIntent);
HeadlessJsTaskService.acquireWakeLockNow(this.getApplicationContext());
Any help would be appreciated
This library is helpful to open app from background state.
React Native Launch Application
If your app is quit from background state
you've to register registerHeadlessTask in index.js like this
AppRegistry.registerHeadlessTask(
'ReactNativeFirebaseMessagingHeadlessTask',
() => notificationActionHandler,
);
and in notificationActionHandler function call libraries function to open app
If your app is in background you can subscribe this
messaging().setBackgroundMessageHandler(remoteMessage => {
console.log('setBackgroundMessageHandler', remoteMessage.data);
})

Push notifications using ConnectyCube on React Native

I'm trying to using push notifications using ConnectyCube on React Native. Main problem is that if I send a notification from the admin panel of ConnectyCube (or from source code), the admin panel says that the notification has been successfully delivered, but nothing happens on the android emulator. Maybe someone can think that there are some bugs client-side in the implementation of my onMessageListener:
notificationListener = firebase.notifications().onNotification((notification) => {
console.log("Hi!")
});
Anyway, if I try to send a notification through the Firebase console, all works and I receive the notification. Can you help me?
It seems that you are using a wrong method: https://rnfirebase.io/docs/v5.x.x/notifications/introduction
The React Native Firebase Notifications Module deals with notification-only and notification + data FCM remote messages.
For data-only FCM messages please see the Messaging module.
ConnectyCube sends a data push messages.
Therefore, please try using Messaging module according to this guide:
https://rnfirebase.io/docs/v5.x.x/messaging/receiving-messages

Different sound to play while receiving notifications in expo

I want to play some other sound like an alert one on receiving a notification.Is it possible yet as it is the most basic functionality?Below is my code:
const receipts = expo.sendPushNotificationsAsync([ { to: userObj.pushToken,
sound: 'default', body: notification, data: { withSome: notification }, priority: 'high' } ]);
Expo push server does not support custom sounds. It will swallow whatever you place in the sound field and replace it with default. Attempting to work around their module using the expo service from curl will give you an actual error.
However, custom sounds are possible in expo clients when using your own APNS module server side if the sound is bundled within the .ipa upon delivery to App Store.

Firebase Cloud Messaging with serverside API push for obj-c

currently I working to implement Firebase Push Notification in my apps.
I found this:
[background] Using Firebase Console my apps can get the notification from system tray with remote notification
[foreground] Using Firebase Console my apps can get the notification from log, but i can make it into notification center with local notification
[foreground] Using Our Dashboard which managed by PHP serverside, I can get notification from log, but i can make it into notification center with local notification
The problem is, how can i get the notification (log is fine) if my apps in background with Our Dashboard which managed by PHP serverside?
I found that there is different between json I got from Firebase Console and our managed serverside dashboard, is that a problem that my apps cant handle? and how i can handle it? can I get the sample of the code to solve this problem?
This is the different between json i got from firebase console and our managed serverside dashboard
firebase console
our managed serverside dashboard
What you want to do is possible by using the normal FCM api.
Please review the differences between Display-Message and Data-Message here:
https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
and see all the parameters in the reference page:
https://firebase.google.com/docs/cloud-messaging/http-server-ref