Skip to content

Commit

Permalink
adding support for background notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
BlakeKaufman committed Oct 5, 2024
1 parent 310d45d commit 841563d
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 26 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,4 @@ web-build/

.npmrc
.yarn/cache
.yarn/install-state.gz


google-services.json
.yarn/install-state.gz
17 changes: 16 additions & 1 deletion App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type RootStackParamList = {
Home: {someParam?: string};
Details: {someParam?: string};
};
import * as TaskManager from 'expo-task-manager';
import * as Notifications from 'expo-notifications';
import {retrieveData} from './app/functions';
// import SplashScreen from 'react-native-splash-screen';

Expand Down Expand Up @@ -359,7 +361,7 @@ function ResetStack(): JSX.Element | null {
return () => {
Linking.removeAllListeners('url');
};
}, [handleDeepLink, getInitialURL]);
}, []);

const handleAnimationFinish = () => {
setIsLoaded(true);
Expand Down Expand Up @@ -683,6 +685,19 @@ function ResetStack(): JSX.Element | null {
);
}

const BACKGROUND_NOTIFICATION_TASK = 'BACKGROUND-NOTIFICATION-TASK';

TaskManager.defineTask(
BACKGROUND_NOTIFICATION_TASK,
({data, error, executionInfo}) => {
console.log('Received a notification in the background!');
console.log(data);
// Do something with the notification data
},
);

Notifications.registerTaskAsync(BACKGROUND_NOTIFICATION_TASK);

// TaskManager.defineTask(
// BACKGROUND_NOTIFICATION_TASK,
// ({data, error, executionInfo}) => {
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ dependencies {
implementation jscFlavor
}

// react-native-notifications
implementation project(':react-native-notifications')
// // react-native-notifications
// implementation project(':react-native-notifications')
implementation 'com.google.firebase:firebase-messaging:23.0.0'
}
30 changes: 30 additions & 0 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"project_info": {
"project_number": "492441809848",
"firebase_url": "https://blitz-wallet-default-rtdb.firebaseio.com",
"project_id": "blitz-wallet",
"storage_bucket": "blitz-wallet.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:492441809848:android:ccd2552c3dfdb1fb9e554d",
"android_client_info": {
"package_name": "com.blitzwallet"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyD0whuYV7aYgj50pjFoiJyT6nwGsIIkdu4"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.blitzwallet
import android.content.res.Configuration
import expo.modules.ApplicationLifecycleDispatcher
import expo.modules.ReactNativeHostWrapper
import com.wix.reactnativenotifications.RNNotificationsPackage

import android.app.Application
import com.facebook.react.PackageList
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
},
"android": {
"googleServicesFile": "./google-services.json"
"googleServicesFile": "./android/app/google-services.json"
},
"owner": "bkaufman20"
}
Expand Down
8 changes: 8 additions & 0 deletions app/functions/messaging/publishMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ async function sendPushNotification({
)} sats`;
}

console.log(
JSON.stringify({
devicePushKey: devicePushKey,
deviceType: deviceType,
message: message,
token: JWT,
}),
);
const response = await fetch(
`https://blitz-wallet.com/.netlify/functions/contactsPushNotification`,
{
Expand Down
35 changes: 18 additions & 17 deletions ios/BlitzWallet/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@
</array>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>mailto</string>
<string>message</string>
<string>readdle-spark</string>
<string>airmail</string>
<string>ms-outlook</string>
<string>googlegmail</string>
<string>inbox-gmail</string>
<string>ymail</string>
<string>superhuman</string>
<string>yandexmail</string>
<string>fastmail</string>
<string>protonmail</string>
<string>szn-email</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down Expand Up @@ -142,26 +158,11 @@
<string>Poppins-Thin.ttf</string>
<string>Poppins-ThinItalic.ttf</string>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>mailto</string>
<string>message</string>
<string>readdle-spark</string>
<string>airmail</string>
<string>ms-outlook</string>
<string>googlegmail</string>
<string>inbox-gmail</string>
<string>ymail</string>
<string>superhuman</string>
<string>yandexmail</string>
<string>fastmail</string>
<string>protonmail</string>
<string>szn-email</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
<string>fetch</string>
<string>processing</string>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string></string>
Expand Down
12 changes: 12 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ PODS:
- ExpoWebBrowser (13.0.3):
- ExpoModulesCore
- EXStructuredHeaders (3.8.0)
- EXTaskManager (11.8.2):
- ExpoModulesCore
- UMAppLoader
- EXUpdates (0.25.26):
- DoubleConversion
- EASClient
Expand Down Expand Up @@ -1892,6 +1895,7 @@ PODS:
- "sqlite3 (3.45.3+1)":
- "sqlite3/common (= 3.45.3+1)"
- "sqlite3/common (3.45.3+1)"
- UMAppLoader (4.6.0)
- VisionCamera (4.5.3):
- VisionCamera/Core (= 4.5.3)
- VisionCamera/React (= 4.5.3)
Expand Down Expand Up @@ -1933,6 +1937,7 @@ DEPENDENCIES:
- ExpoSpeech (from `../node_modules/expo-speech/ios`)
- ExpoWebBrowser (from `../node_modules/expo-web-browser/ios`)
- EXStructuredHeaders (from `../node_modules/expo-structured-headers/ios`)
- EXTaskManager (from `../node_modules/expo-task-manager/ios`)
- EXUpdates (from `../node_modules/expo-updates/ios`)
- EXUpdatesInterface (from `../node_modules/expo-updates-interface/ios`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
Expand Down Expand Up @@ -2014,6 +2019,7 @@ DEPENDENCIES:
- RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`)
- RNSVG (from `../node_modules/react-native-svg`)
- UMAppLoader (from `../node_modules/unimodules-app-loader/ios`)
- VisionCamera (from `../node_modules/react-native-vision-camera`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

Expand Down Expand Up @@ -2085,6 +2091,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/expo-web-browser/ios"
EXStructuredHeaders:
:path: "../node_modules/expo-structured-headers/ios"
EXTaskManager:
:path: "../node_modules/expo-task-manager/ios"
EXUpdates:
:path: "../node_modules/expo-updates/ios"
EXUpdatesInterface:
Expand Down Expand Up @@ -2244,6 +2252,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-screens"
RNSVG:
:path: "../node_modules/react-native-svg"
UMAppLoader:
:path: "../node_modules/unimodules-app-loader/ios"
VisionCamera:
:path: "../node_modules/react-native-vision-camera"
Yoga:
Expand Down Expand Up @@ -2279,6 +2289,7 @@ SPEC CHECKSUMS:
ExpoSpeech: 258ea713923eb70ef63d3bdb14f47a462d0b6f0e
ExpoWebBrowser: 7595ccac6938eb65b076385fd23d035db9ecdc8e
EXStructuredHeaders: cb8d1f698e144f4c5547b4c4963e1552f5d2b457
EXTaskManager: 9c3520305c3aa1b4a12a7c6d1e3f85f2779c06e9
EXUpdates: 61e1a3414212263761b16731611cc174e3eda376
EXUpdatesInterface: 996527fd7d1a5d271eb523258d603f8f92038f24
FBLazyVector: 38bb611218305c3bc61803e287b8a81c6f63b619
Expand Down Expand Up @@ -2365,6 +2376,7 @@ SPEC CHECKSUMS:
RNSVG: 4590aa95758149fa27c5c83e54a6a466349a1688
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
sqlite3: 02d1f07eaaa01f80a1c16b4b31dfcbb3345ee01a
UMAppLoader: f17a5ee8e85b536ace0fc254b447a37ed198d57e
VisionCamera: cb84d0d8485b3e67c91b62931d3aa88f49747c92
Yoga: a1d7895431387402a674fd0d1c04ec85e87909b8
ZXingObjC: 8898711ab495761b2dbbdec76d90164a6d7e14c5
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"expo-secure-store": "~13.0.2",
"expo-speech": "~12.0.2",
"expo-status-bar": "~1.12.1",
"expo-task-manager": "~11.8.2",
"expo-updates": "~0.25.26",
"expo-web-browser": "~13.0.3",
"firebase": "^10.14.0",
Expand Down
19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4979,6 +4979,7 @@ __metadata:
expo-secure-store: ~13.0.2
expo-speech: ~12.0.2
expo-status-bar: ~1.12.1
expo-task-manager: ~11.8.2
expo-updates: ~0.25.26
expo-web-browser: ~13.0.3
firebase: ^10.14.0
Expand Down Expand Up @@ -8269,6 +8270,17 @@ __metadata:
languageName: node
linkType: hard

"expo-task-manager@npm:~11.8.2":
version: 11.8.2
resolution: "expo-task-manager@npm:11.8.2"
dependencies:
unimodules-app-loader: ~4.6.0
peerDependencies:
expo: "*"
checksum: ebc0ebb23ce357cfe8be1c19bf781551ea71b40aac69b85814558cf9233b36596241c7b905512bcc174f148aa7d66cd67d2c755747ee16d1359264fc6376ac81
languageName: node
linkType: hard

"expo-updates-interface@npm:~0.16.2":
version: 0.16.2
resolution: "expo-updates-interface@npm:0.16.2"
Expand Down Expand Up @@ -15115,6 +15127,13 @@ __metadata:
languageName: node
linkType: hard

"unimodules-app-loader@npm:~4.6.0":
version: 4.6.0
resolution: "unimodules-app-loader@npm:4.6.0"
checksum: 20897153b02f5436d51090ae30863950abec6a0438e460f4e5561bd155273c2a6eea626d1135fc8b07f5a57c1969e24f89b4ae4d5df198266ee88719db10444d
languageName: node
linkType: hard

"unique-filename@npm:^3.0.0":
version: 3.0.0
resolution: "unique-filename@npm:3.0.0"
Expand Down

0 comments on commit 841563d

Please sign in to comment.