Skip to content

Commit

Permalink
Try to fix crashes on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
robertying committed Oct 17, 2024
1 parent d1b3085 commit 2d0d063
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
6 changes: 1 addition & 5 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ module.exports = {
},
],
'preval',
'react-native-paper/babel',
'react-native-reanimated/plugin',
],
env: {
production: {
plugins: ['react-native-paper/babel'],
},
},
};
28 changes: 28 additions & 0 deletions patches/expo-notifications+0.28.18.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/node_modules/expo-notifications/build/getDevicePushTokenAsync.js b/node_modules/expo-notifications/build/getDevicePushTokenAsync.js
index 5deaa81..2b1cf95 100644
--- a/node_modules/expo-notifications/build/getDevicePushTokenAsync.js
+++ b/node_modules/expo-notifications/build/getDevicePushTokenAsync.js
@@ -7,6 +7,9 @@ let nativeTokenPromise = null;
* @header fetch
*/
export default async function getDevicePushTokenAsync() {
+ if (Platform.OS === 'android') {
+ throw new Error("Push notifications are not supported on Android.");
+ }
if (!PushTokenManager.getDevicePushTokenAsync) {
throw new UnavailabilityError('ExpoNotifications', 'getDevicePushTokenAsync');
}
diff --git a/node_modules/expo-notifications/build/getExpoPushTokenAsync.js b/node_modules/expo-notifications/build/getExpoPushTokenAsync.js
index b313f88..88578ad 100644
--- a/node_modules/expo-notifications/build/getExpoPushTokenAsync.js
+++ b/node_modules/expo-notifications/build/getExpoPushTokenAsync.js
@@ -43,6 +43,9 @@ const productionBaseUrl = 'https://exp.host/--/api/v2/';
* ```
*/
export default async function getExpoPushTokenAsync(options = {}) {
+ if (Platform.OS === 'android') {
+ throw new Error("Push notifications are not supported on Android.");
+ }
const devicePushToken = options.devicePushToken || (await getDevicePushTokenAsync());
const deviceId = options.deviceId || (await getDeviceIdAsync());
const projectId = options.projectId || Constants.easConfig?.projectId;
3 changes: 1 addition & 2 deletions src/helpers/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ export const setUpPushNotifications = async () => {
if (Platform.OS !== 'ios') {
return;
}
console.log('hi');

if (!(await registerForPushNotifications())) {
return;
}
console.log('hello');

Notifications.setNotificationHandler({
handleNotification: async () => ({
Expand Down

0 comments on commit 2d0d063

Please sign in to comment.