diff --git a/.gitignore b/.gitignore index f8c6c2e..e352b46 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,6 @@ app-example # generated native folders /ios /android + + +google-services.json diff --git a/app.json b/app.json index c578a91..2f111a3 100644 --- a/app.json +++ b/app.json @@ -3,13 +3,23 @@ "name": "my-drawer-app", "slug": "my-drawer-app", "version": "1.0.0", + "projectId": "361036ad-f0cf-41d1-ba27-d3f39f6019dc", "orientation": "portrait", "icon": "./assets/images/icon.png", "scheme": "mydrawerapp", "userInterfaceStyle": "automatic", "newArchEnabled": true, "ios": { - "supportsTablet": true + "supportsTablet": true, + "bundleIdentifier": "com.anonymous.mydrawerapp", + "buildNumber": "1.0.0", + "infoPlist": { + "UIBackgroundModes": [ + "remote-notification" + ], + "NSUserTrackingUsageDescription": "This identifier will be used to deliver personalized notifications.", + "NSUserNotificationUsageDescription": "This app uses notifications to keep you informed." + } }, "android": { "adaptiveIcon": { @@ -19,7 +29,13 @@ "monochromeImage": "./assets/images/android-icon-monochrome.png" }, "edgeToEdgeEnabled": true, - "predictiveBackGestureEnabled": false + "predictiveBackGestureEnabled": false, + "package": "com.anonymous.mydrawerapp", + "versionCode": 1, + "permissions": [ + "NOTIFICATIONS" + ], + "googleServicesFile": "./google-services.json" }, "web": { "output": "static", @@ -38,11 +54,26 @@ "backgroundColor": "#000000" } } + ], + [ + "expo-notifications", + { + "icon": "./assets/images/notification-icon.png", + "color": "#000000", + "androidMode": "default", + "androidCollapsedTitle": "New notification" + } ] ], "experiments": { "typedRoutes": true, "reactCompiler": true + }, + "extra": { + "router": {}, + "eas": { + "projectId": "630e211b-f7de-4a82-a863-5962a593f5aa" + } } } } diff --git a/assets/images/notification-icon.png b/assets/images/notification-icon.png new file mode 100755 index 0000000..b8178d7 Binary files /dev/null and b/assets/images/notification-icon.png differ diff --git a/eas.json b/eas.json new file mode 100644 index 0000000..464c30b --- /dev/null +++ b/eas.json @@ -0,0 +1,21 @@ +{ + "cli": { + "version": ">= 16.20.0", + "appVersionSource": "remote" + }, + "build": { + "development": { + "developmentClient": true, + "distribution": "internal" + }, + "preview": { + "distribution": "internal" + }, + "production": { + "autoIncrement": true + } + }, + "submit": { + "production": {} + } +} diff --git a/hooks/usePushNotifications.ts b/hooks/usePushNotifications.ts index c53363e..eec126b 100644 --- a/hooks/usePushNotifications.ts +++ b/hooks/usePushNotifications.ts @@ -1,5 +1,5 @@ +import * as Device from "expo-device"; import * as Notifications from "expo-notifications"; -import * as Permissions from "expo-permissions"; import { useEffect, useState } from "react"; import { Platform } from "react-native"; @@ -59,9 +59,20 @@ export function usePushNotifications({ } async function registerForPushNotificationsAsync() { - let { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS); + if (!Device.isDevice) { + console.log("Must use physical device for Push Notifications"); + return null; + } - if (status !== "granted") { + const { status: existingStatus } = await Notifications.getPermissionsAsync(); + let finalStatus = existingStatus; + + if (existingStatus !== "granted") { + const { status } = await Notifications.requestPermissionsAsync(); + finalStatus = status; + } + + if (finalStatus !== "granted") { console.log("Permission not granted for push notifications."); return null; } @@ -69,5 +80,16 @@ async function registerForPushNotificationsAsync() { const tokenData = await Notifications.getExpoPushTokenAsync(); const token = tokenData.data; console.log("Expo Push Token:", token); + + // Android-specific setup + if (Platform.OS === "android") { + await Notifications.setNotificationChannelAsync("default", { + name: "default", + importance: Notifications.AndroidImportance.MAX, + vibrationPattern: [0, 250, 250, 250], + lightColor: "#FF231F7C" + }); + } + return token; } diff --git a/package-lock.json b/package-lock.json index b47bdc8..84c9302 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,9 @@ "dependencies": { "@expo/metro-runtime": "~6.1.2", "@expo/vector-icons": "^15.0.2", - "expo": "~54.0.10", + "expo": "^54.0.10", "expo-constants": "~18.0.9", + "expo-dev-client": "~6.0.12", "expo-device": "~8.0.8", "expo-font": "~14.0.8", "expo-haptics": "~15.0.7", @@ -6386,6 +6387,56 @@ "react-native": "*" } }, + "node_modules/expo-dev-client": { + "version": "6.0.12", + "resolved": "https://registry.npmjs.org/expo-dev-client/-/expo-dev-client-6.0.12.tgz", + "integrity": "sha512-Knr2abq0r6ALASsZtrX9QD4V0vP4ZL18iDVF5lgr6iFYawbuqQHuJRktIUETimu6qLusJK8Z3kZRabAdNqT+qw==", + "license": "MIT", + "dependencies": { + "expo-dev-launcher": "6.0.11", + "expo-dev-menu": "7.0.11", + "expo-dev-menu-interface": "2.0.0", + "expo-manifests": "~1.0.8", + "expo-updates-interface": "~2.0.0" + }, + "peerDependencies": { + "expo": "*" + } + }, + "node_modules/expo-dev-launcher": { + "version": "6.0.11", + "resolved": "https://registry.npmjs.org/expo-dev-launcher/-/expo-dev-launcher-6.0.11.tgz", + "integrity": "sha512-5wcuevQ8l57uWVqHWpARwZb57doUbzPxorhJXpYLza1tJbkuQBb1lpjeJ1Di47bGMDq0jRw6yMFkF6N9nKX/OQ==", + "license": "MIT", + "dependencies": { + "expo-dev-menu": "7.0.11", + "expo-manifests": "~1.0.8" + }, + "peerDependencies": { + "expo": "*" + } + }, + "node_modules/expo-dev-menu": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/expo-dev-menu/-/expo-dev-menu-7.0.11.tgz", + "integrity": "sha512-xJ2scPxfHKyANTMgexK9tH7xunhsPEynuwpsssiS2syCWzvo+Mtv3euOLlkUb/IRt1JTKDxTMZBgChkaq5juSQ==", + "license": "MIT", + "dependencies": { + "expo-dev-menu-interface": "2.0.0" + }, + "peerDependencies": { + "expo": "*" + } + }, + "node_modules/expo-dev-menu-interface": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/expo-dev-menu-interface/-/expo-dev-menu-interface-2.0.0.tgz", + "integrity": "sha512-BvAMPt6x+vyXpThsyjjOYyjwfjREV4OOpQkZ0tNl+nGpsPfcY9mc6DRACoWnH9KpLzyIt3BOgh3cuy/h/OxQjw==", + "license": "MIT", + "peerDependencies": { + "expo": "*" + } + }, "node_modules/expo-device": { "version": "8.0.8", "resolved": "https://registry.npmjs.org/expo-device/-/expo-device-8.0.8.tgz", @@ -6474,6 +6525,12 @@ } } }, + "node_modules/expo-json-utils": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/expo-json-utils/-/expo-json-utils-0.15.0.tgz", + "integrity": "sha512-duRT6oGl80IDzH2LD2yEFWNwGIC2WkozsB6HF3cDYNoNNdUvFk6uN3YiwsTsqVM/D0z6LEAQ01/SlYvN+Fw0JQ==", + "license": "MIT" + }, "node_modules/expo-keep-awake": { "version": "15.0.7", "resolved": "https://registry.npmjs.org/expo-keep-awake/-/expo-keep-awake-15.0.7.tgz", @@ -6498,6 +6555,19 @@ "react-native": "*" } }, + "node_modules/expo-manifests": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/expo-manifests/-/expo-manifests-1.0.8.tgz", + "integrity": "sha512-nA5PwU2uiUd+2nkDWf9e71AuFAtbrb330g/ecvuu52bmaXtN8J8oiilc9BDvAX0gg2fbtOaZdEdjBYopt1jdlQ==", + "license": "MIT", + "dependencies": { + "@expo/config": "~12.0.8", + "expo-json-utils": "~0.15.0" + }, + "peerDependencies": { + "expo": "*" + } + }, "node_modules/expo-modules-autolinking": { "version": "3.0.13", "resolved": "https://registry.npmjs.org/expo-modules-autolinking/-/expo-modules-autolinking-3.0.13.tgz", @@ -6698,6 +6768,15 @@ } } }, + "node_modules/expo-updates-interface": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/expo-updates-interface/-/expo-updates-interface-2.0.0.tgz", + "integrity": "sha512-pTzAIufEZdVPKql6iMi5ylVSPqV1qbEopz9G6TSECQmnNde2nwq42PxdFBaUEd8IZJ/fdJLQnOT3m6+XJ5s7jg==", + "license": "MIT", + "peerDependencies": { + "expo": "*" + } + }, "node_modules/expo-web-browser": { "version": "15.0.7", "resolved": "https://registry.npmjs.org/expo-web-browser/-/expo-web-browser-15.0.7.tgz", diff --git a/package.json b/package.json index 6ac2cdd..f81dac8 100644 --- a/package.json +++ b/package.json @@ -5,16 +5,17 @@ "scripts": { "start": "expo start", "reset-project": "node ./scripts/reset-project.js", - "android": "expo start --android", - "ios": "expo start --ios", + "android": "expo run:android", + "ios": "expo run:ios", "web": "expo start --web", "lint": "expo lint" }, "dependencies": { "@expo/metro-runtime": "~6.1.2", "@expo/vector-icons": "^15.0.2", - "expo": "~54.0.10", + "expo": "^54.0.10", "expo-constants": "~18.0.9", + "expo-dev-client": "~6.0.12", "expo-device": "~8.0.8", "expo-font": "~14.0.8", "expo-haptics": "~15.0.7",