diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 1319cbe..3a5ebac 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -17,9 +17,11 @@ - + + + diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 5c7a9f1..4713052 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -3,4 +3,5 @@ contain false light + 1.0.0 \ No newline at end of file diff --git a/app.json b/app.json index f1836a4..a73d188 100644 --- a/app.json +++ b/app.json @@ -24,7 +24,11 @@ "backgroundColor": "#ffffff" }, "package": "com.cally.app", - "googleServicesFile": "./android/app/google-services.json" + "googleServicesFile": "./android/app/google-services.json", + "permissions": [ + "android.permission.CAMERA", + "android.permission.RECORD_AUDIO" + ] }, "web": { "bundler": "metro", @@ -70,6 +74,10 @@ "eas": { "projectId": "bdb8c57b-25bb-4d36-b3b8-5b09c5092f52" } + }, + "runtimeVersion": "1.0.0", + "updates": { + "url": "https://u.expo.dev/bdb8c57b-25bb-4d36-b3b8-5b09c5092f52" } } } diff --git a/eas.json b/eas.json index a45666d..e022e28 100644 --- a/eas.json +++ b/eas.json @@ -5,12 +5,16 @@ "build": { "development": { "developmentClient": true, - "distribution": "internal" + "distribution": "internal", + "channel": "development" }, "preview": { - "distribution": "internal" + "distribution": "internal", + "channel": "preview" }, - "production": {} + "production": { + "channel": "production" + } }, "submit": { "production": { diff --git a/firebase/functions/index.js b/firebase/functions/index.js index 43e13ee..37e0c53 100644 --- a/firebase/functions/index.js +++ b/firebase/functions/index.js @@ -16,8 +16,14 @@ exports.sendNotificationOnEventCreation = functions.firestore .document('Events/{eventId}') .onCreate(async (snapshot, context) => { const eventData = snapshot.data(); + const { familyId, creatorId } = eventData; - const pushTokens = await getPushTokensForEvent(eventData); + if (!familyId || !creatorId) { + console.error('Missing familyId or creatorId in event data'); + return; + } + + const pushTokens = await getPushTokensForFamilyExcludingCreator(familyId, creatorId); if (!pushTokens.length) { console.log('No push tokens available for the event.'); @@ -36,7 +42,7 @@ exports.sendNotificationOnEventCreation = functions.firestore sound: 'default', title: 'New Event Added!', body: `An event "${eventData.title}" has been added. Check it out!`, - data: {eventId: context.params.eventId}, + data: { eventId: context.params.eventId }, }); } @@ -45,7 +51,6 @@ exports.sendNotificationOnEventCreation = functions.firestore for (let chunk of chunks) { try { let ticketChunk = await expo.sendPushNotificationsAsync(chunk); - tickets.push(...ticketChunk); for (let ticket of ticketChunk) { @@ -53,7 +58,6 @@ exports.sendNotificationOnEventCreation = functions.firestore console.log('Notification successfully sent:', ticket.id); } else if (ticket.status === 'error') { console.error(`Notification error: ${ticket.message}`); - if (ticket.details && ticket.details.error) { console.error('Error details:', ticket.details.error); if (ticket.details.error === 'DeviceNotRegistered') { @@ -63,12 +67,12 @@ exports.sendNotificationOnEventCreation = functions.firestore } } } - } catch (error) { console.error('Error sending notification:', error); } } + // Retrieve and handle notification receipts let receiptIds = []; for (let ticket of tickets) { if (ticket.id) { @@ -84,7 +88,6 @@ exports.sendNotificationOnEventCreation = functions.firestore for (let receiptId in receipts) { let { status, message, details } = receipts[receiptId]; - if (status === 'ok') { console.log(`Notification with receipt ID ${receiptId} was delivered successfully`); } else if (status === 'error') { @@ -99,7 +102,6 @@ exports.sendNotificationOnEventCreation = functions.firestore } } - return null; }); @@ -207,3 +209,18 @@ async function getPushTokensForEvent() { return pushTokens; } +async function getPushTokensForFamilyExcludingCreator(familyId, creatorId) { + const usersRef = db.collection('Profiles'); + const snapshot = await usersRef.where('familyId', '==', familyId).get(); + let pushTokens = []; + + snapshot.forEach(doc => { + const data = doc.data(); + // Exclude the creator + if (data.uid !== creatorId && data.pushToken) { + pushTokens.push(data.pushToken); + } + }); + + return pushTokens; +} diff --git a/hooks/firebase/useCreateEvent.ts b/hooks/firebase/useCreateEvent.ts index c7efcfc..09eceaf 100644 --- a/hooks/firebase/useCreateEvent.ts +++ b/hooks/firebase/useCreateEvent.ts @@ -4,7 +4,7 @@ import firestore from "@react-native-firebase/firestore"; import { EventData } from "@/hooks/firebase/types/eventData"; export const useCreateEvent = () => { - const {user: currentUser} = useAuthContext() + const {user: currentUser, profileData} = useAuthContext() const queryClients = useQueryClient() return useMutation({ @@ -14,7 +14,7 @@ export const useCreateEvent = () => { console.log("CALLLLL") await firestore() .collection("Events") - .add({...eventData, creatorId: currentUser?.uid}) + .add({...eventData, creatorId: currentUser?.uid, familyId: profileData?.familyId}) } catch (e) { console.error(e) } diff --git a/ios/cally/Info.plist b/ios/cally/Info.plist index 553278d..0bab191 100644 --- a/ios/cally/Info.plist +++ b/ios/cally/Info.plist @@ -86,6 +86,9 @@ $(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route $(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route $(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route + $(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route + $(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route + $(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route UILaunchStoryboardName SplashScreen diff --git a/ios/cally/Supporting/Expo.plist b/ios/cally/Supporting/Expo.plist index 750be02..a0a9a33 100644 --- a/ios/cally/Supporting/Expo.plist +++ b/ios/cally/Supporting/Expo.plist @@ -5,8 +5,12 @@ EXUpdatesCheckOnLaunch ALWAYS EXUpdatesEnabled - + EXUpdatesLaunchWaitMs 0 + EXUpdatesRuntimeVersion + 1.0.0 + EXUpdatesURL + https://u.expo.dev/bdb8c57b-25bb-4d36-b3b8-5b09c5092f52 \ No newline at end of file diff --git a/package.json b/package.json index b195298..e69425e 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "lint": "expo lint", "submit": "npx eas-cli submit -p ios", "prebuild": "npx expo prebuild -p ios", - "prebuild-build-submit-ios": "npm run prebuild && npm run build-ios && npm run submit", + "prebuild-build-submit-ios": "yarn run prebuild && yarn run build-ios && yarn run submit", "prebuild-build-submit-ios-cicd": "yarn build-ios-cicd", "prebuild-build-submit-cicd": "yarn build-cicd" }, @@ -55,6 +55,7 @@ "expo-splash-screen": "~0.27.5", "expo-status-bar": "~1.12.1", "expo-system-ui": "~3.0.7", + "expo-updates": "~0.25.27", "expo-web-browser": "~13.0.3", "firebase-admin": "^12.3.1", "firebase-functions": "^5.1.0", diff --git a/yarn.lock b/yarn.lock index 76c74a5..52158be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1018,6 +1018,20 @@ dotenv-expand "~11.0.6" getenv "^1.0.0" +"@expo/fingerprint@^0.10.2": + version "0.10.3" + resolved "https://registry.yarnpkg.com/@expo/fingerprint/-/fingerprint-0.10.3.tgz#87c2811fe7773ec7d00cae86ab041d578f9041b5" + integrity sha512-h/BnnyloJyMSrzeXonKLE6HfiMpRg3e9m8CAv+eUaAozG9heKMG9ftHW4cfm2StDYj/rWjFc5YK6MSIX6qd+xg== + dependencies: + "@expo/spawn-async" "^1.7.2" + chalk "^4.1.2" + debug "^4.3.4" + find-up "^5.0.0" + minimatch "^3.0.4" + p-limit "^3.1.0" + resolve-from "^5.0.0" + semver "^7.6.0" + "@expo/image-utils@^0.5.0": version "0.5.1" resolved "https://registry.npmjs.org/@expo/image-utils/-/image-utils-0.5.1.tgz" @@ -3228,6 +3242,11 @@ application-config-path@^0.1.0: resolved "https://registry.npmjs.org/application-config-path/-/application-config-path-0.1.1.tgz" integrity sha512-zy9cHePtMP0YhwG+CfHm0bgwdnga2X3gZexpdCwEj//dpb+TKajtiC8REEUJUSq6Ab4f9cgNy2l8ObXzCXFkEw== +arg@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.0.tgz#583c518199419e0037abb74062c37f8519e575f0" + integrity sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg== + arg@5.0.2: version "5.0.2" resolved "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz" @@ -4945,6 +4964,11 @@ expo-device@~6.0.2: dependencies: ua-parser-js "^0.7.33" +expo-eas-client@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/expo-eas-client/-/expo-eas-client-0.12.0.tgz#e8b6f7d33873e6f630f37f7bfc41646ae7b0b2a9" + integrity sha512-Jkww9Cwpv0z7DdLYiRX0r4fqBEcI9cKqTn7cHx63S09JaZ2rcwEE4zYHgrXwjahO+tU2VW8zqH+AJl6RhhW4zA== + expo-file-system@~17.0.1: version "17.0.1" resolved "https://registry.npmjs.org/expo-file-system/-/expo-file-system-17.0.1.tgz" @@ -5056,6 +5080,11 @@ expo-status-bar@~1.12.1: resolved "https://registry.npmjs.org/expo-status-bar/-/expo-status-bar-1.12.1.tgz" integrity sha512-/t3xdbS8KB0prj5KG5w7z+wZPFlPtkgs95BsmrP/E7Q0xHXTcDcQ6Cu2FkFuRM+PKTb17cJDnLkawyS5vDLxMA== +expo-structured-headers@~3.8.0: + version "3.8.0" + resolved "https://registry.yarnpkg.com/expo-structured-headers/-/expo-structured-headers-3.8.0.tgz#11797a4c3a7a6770b21126cecffcda148030e361" + integrity sha512-R+gFGn0x5CWl4OVlk2j1bJTJIz4KO8mPoCHpRHmfqMjmrMvrOM0qQSY3V5NHXwp1yT/L2v8aUmFQsBRIdvi1XA== + expo-system-ui@~3.0.7: version "3.0.7" resolved "https://registry.npmjs.org/expo-system-ui/-/expo-system-ui-3.0.7.tgz" @@ -5069,6 +5098,27 @@ expo-updates-interface@~0.16.2: resolved "https://registry.npmjs.org/expo-updates-interface/-/expo-updates-interface-0.16.2.tgz" integrity sha512-929XBU70q5ELxkKADj1xL0UIm3HvhYhNAOZv5DSk7rrKvLo7QDdPyl+JVnwZm9LrkNbH4wuE2rLoKu1KMgZ+9A== +expo-updates@~0.25.27: + version "0.25.27" + resolved "https://registry.yarnpkg.com/expo-updates/-/expo-updates-0.25.27.tgz#4aff889fea2aa221d8341a902646288f84c48b9e" + integrity sha512-1hyYZqBEXcAiEuSRPJ6dINTndGlWi6/bwlyYGjSnyoYfu/vzZQrJ+XA8JUP4EvJ3b0g8a0UOIjlDJ9ke9kMcfg== + dependencies: + "@expo/code-signing-certificates" "0.0.5" + "@expo/config" "~9.0.0-beta.0" + "@expo/config-plugins" "~8.0.8" + "@expo/fingerprint" "^0.10.2" + "@expo/spawn-async" "^1.7.2" + arg "4.1.0" + chalk "^4.1.2" + expo-eas-client "~0.12.0" + expo-manifests "~0.14.0" + expo-structured-headers "~3.8.0" + expo-updates-interface "~0.16.2" + fast-glob "^3.3.2" + fbemitter "^3.0.0" + ignore "^5.3.1" + resolve-from "^5.0.0" + expo-web-browser@~13.0.0, expo-web-browser@~13.0.3: version "13.0.3" resolved "https://registry.npmjs.org/expo-web-browser/-/expo-web-browser-13.0.3.tgz" @@ -5963,7 +6013,7 @@ ieee754@^1.1.13: resolved "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz" integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== -ignore@^5.2.0: +ignore@^5.2.0, ignore@^5.3.1: version "5.3.2" resolved "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz" integrity sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==