fixing push notifications in ios

This commit is contained in:
balzack 2023-03-06 14:07:42 -08:00
parent 6ee9bd87d0
commit 417f35e418
6 changed files with 31 additions and 14 deletions

View File

@ -1,6 +0,0 @@
{
"$schema": "./node_modules/@react-native-firebase/app/firebase-schema.json",
"react-native": {
"messaging_ios_auto_register_for_remote_messages": false
}
}

View File

@ -9,9 +9,8 @@ import App from './App';
import {name as appName} from './app.json';
import messaging from '@react-native-firebase/messaging';
messaging().registerDeviceForRemoteMessages().then(() => {}).catch((err) => {
console.log(err);
});
messaging().registerDeviceForRemoteMessages().then(() => {});
messaging().setBackgroundMessageHandler(async remoteMessage => {});
AppRegistry.registerComponent(appName, () => App);

View File

@ -44,6 +44,7 @@
5B7EB9410499542E8C5724F5 /* Pods-Databag-DatabagTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Databag-DatabagTests.debug.xcconfig"; path = "Target Support Files/Pods-Databag-DatabagTests/Pods-Databag-DatabagTests.debug.xcconfig"; sourceTree = "<group>"; };
7B13A773299E21170048D0DD /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
7B6135A229B439B80094A6E7 /* login.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = login.png; sourceTree = "<group>"; };
7B6135A429B68A7B0094A6E7 /* Databag.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = Databag.entitlements; path = Databag/Databag.entitlements; sourceTree = "<group>"; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = Databag/LaunchScreen.storyboard; sourceTree = "<group>"; };
89C6BE57DB24E9ADA2F236DE /* Pods-Databag-DatabagTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Databag-DatabagTests.release.xcconfig"; path = "Target Support Files/Pods-Databag-DatabagTests/Pods-Databag-DatabagTests.release.xcconfig"; sourceTree = "<group>"; };
9462C028F47F083241BB7941 /* Pods_Databag.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Databag.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@ -90,6 +91,7 @@
13B07FAE1A68108700A75B9A /* Databag */ = {
isa = PBXGroup;
children = (
7B6135A429B68A7B0094A6E7 /* Databag.entitlements */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
13B07FB01A68108700A75B9A /* AppDelegate.mm */,
13B07FB51A68108700A75B9A /* Images.xcassets */,
@ -508,6 +510,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Databag/Databag.entitlements;
CURRENT_PROJECT_VERSION = 34;
DEVELOPMENT_TEAM = 3P65PQ7SUR;
ENABLE_BITCODE = NO;
@ -541,6 +544,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Databag/Databag.entitlements;
CURRENT_PROJECT_VERSION = 34;
DEVELOPMENT_TEAM = 3P65PQ7SUR;
INFOPLIST_FILE = Databag/Info.plist;

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>

View File

@ -35,12 +35,12 @@
</dict>
</dict>
</dict>
<key>NSMicrophoneUsageDescription</key>
<string>Required for build but not used</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Used to set profile image and post photos</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSMicrophoneUsageDescription</key>
<string>Required for build but not used</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Used to set profile image and post photos</string>
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
@ -60,6 +60,11 @@
<string>SimpleLineIcons.ttf</string>
<string>Zocial.ttf</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>

View File

@ -1,4 +1,5 @@
import { useEffect, useState, useRef, useContext } from 'react';
import { Alert } from 'react-native';
import { setLogin } from 'api/setLogin';
import { clearLogin } from 'api/clearLogin';
import { removeProfile } from 'api/removeProfile';
@ -40,7 +41,13 @@ export function useAppContext() {
useEffect(() => {
(async () => {
try {
deviceToken.current = await messaging().getToken();
try {
deviceToken.current = await messaging().getToken();
}
catch (err) {
console.log(err);
Alert.alert('FCM', err.toString());
}
}
catch (err) {
console.log(err);