https://rnfirebase.io/messaging/usage
Under the section iOS - Requesting permissions
Wrong:
import messaging, { AuthorizationStatus } from '@react-native-firebase/messaging';
This import is incorrect and AuthorizationStatus is undefined when imported this way.
Instead import only messaging
import messaging from '@react-native-firebase/messaging';
and use AuthorizationStatus as below
const enabled = (authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
authStatus === messaging.AuthorizationStatus.PROVISIONAL);
iOS
"@react-native-firebase/app": "7.3.0",
"@react-native-firebase/messaging": "7.1.7",
There's an "edit page" button at the top of that page. If you click it, you can make a super quick edit and PR for us to merge! 馃檪
I'm not sure the premise is correct though perhaps I just have a different view coming at it from typescript
My usage looks like this:
(base) mike@kunashir:~/work/Kullki/ksocialscore/packages/public-app/src (rebranding) % grep -r FirebaseMessagingTypes *
app/AppBootstrapperNative.tsx:import { FirebaseMessagingTypes } from '@react-native-firebase/messaging';
app/AppBootstrapperNative.tsx: (message: FirebaseMessagingTypes.RemoteMessage): Promise<null> => {
services/BackgroundTaskService.ts:import { FirebaseMessagingTypes } from '@react-native-firebase/messaging';
services/BackgroundTaskService.ts: firebase.messaging().onMessage((message: FirebaseMessagingTypes.RemoteMessage) => {
services/BackgroundTaskService.ts: public cloudMessageHandler = (message: FirebaseMessagingTypes.RemoteMessage) => {
services/BackgroundTaskService.ts: message: FirebaseMessagingTypes.RemoteMessage
services/BackgroundTaskService.ts: let enabled = FirebaseMessagingTypes.AuthorizationStatus.NOT_DETERMINED;
services/BackgroundTaskService.ts: if (enabled !== FirebaseMessagingTypes.AuthorizationStatus.DENIED) {
And you know with Typescript you don't get to guess about imports and types, they work, or they don't. This works?
@mikehardy this is correct, it's a static variable on the messaging instance so has to be messaging.AuthorizationStatus.AUTHORIZED when not using TypesScript
Most helpful comment
@mikehardy this is correct, it's a static variable on the messaging instance so has to be
messaging.AuthorizationStatus.AUTHORIZEDwhen not using TypesScript