Sfoglia il codice sorgente

sentry ios small fix

Viktoriia 1 giorno fa
parent
commit
eaef4cb807
1 ha cambiato i file con 14 aggiunte e 6 eliminazioni
  1. 14 6
      src/utils/pushNotificationTask.ts

+ 14 - 6
src/utils/pushNotificationTask.ts

@@ -86,18 +86,26 @@ TaskManager.defineTask(
 );
 
 export const registerBackgroundNotificationTask = async () => {
-  const isRegistered = await TaskManager.isTaskRegisteredAsync(BACKGROUND_NOTIFICATION_TASK);
+  try {
+    const isRegistered = await TaskManager.isTaskRegisteredAsync(BACKGROUND_NOTIFICATION_TASK);
 
-  if (!isRegistered && Platform.OS === 'ios') {
-    await Notifications.registerTaskAsync(BACKGROUND_NOTIFICATION_TASK);
+    if (!isRegistered && Platform.OS === 'ios') {
+      await Notifications.registerTaskAsync(BACKGROUND_NOTIFICATION_TASK);
+    }
+  } catch (error) {
+    console.warn('Background notification task registration failed:', error);
   }
 };
 
 export const unregisterBackgroundNotificationTask = async () => {
-  const isRegistered = await TaskManager.isTaskRegisteredAsync(BACKGROUND_NOTIFICATION_TASK);
+  try {
+    const isRegistered = await TaskManager.isTaskRegisteredAsync(BACKGROUND_NOTIFICATION_TASK);
 
-  if (isRegistered) {
-    await TaskManager.unregisterTaskAsync(BACKGROUND_NOTIFICATION_TASK);
+    if (isRegistered) {
+      await TaskManager.unregisterTaskAsync(BACKGROUND_NOTIFICATION_TASK);
+    }
+  } catch (error) {
+    console.warn('Background notification task unregistration failed:', error);
   }
 };