migrated to expo notifications
This commit is contained in:
+4
-1
@@ -76,4 +76,7 @@ web-build/
|
||||
|
||||
.npmrc
|
||||
.yarn/cache
|
||||
.yarn/install-state.gz
|
||||
.yarn/install-state.gz
|
||||
|
||||
|
||||
google-services.json
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
@@ -26,8 +26,8 @@ allprojects {
|
||||
name = "GitHubPackages"
|
||||
url = uri("https://maven.pkg.github.com/blockstream/lwk")
|
||||
credentials {
|
||||
username = System.getenv("user")
|
||||
password = System.getenv("token")
|
||||
username = System.getenv("GITHUB_USER")
|
||||
password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
}
|
||||
maven {
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
"projectId": "edf13405-7014-4f88-aee5-ec131bfc217d"
|
||||
}
|
||||
},
|
||||
"android": {
|
||||
"googleServicesFile": "./google-services.json"
|
||||
},
|
||||
"owner": "bkaufman20"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ async function sendPushNotification({
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
`${getGiftCardAPIEndpoint()}.netlify/functions/contactsPushNotification`,
|
||||
`https://blitz-wallet.com/.netlify/functions/contactsPushNotification`,
|
||||
{
|
||||
method: 'POST', // Specify the HTTP method
|
||||
headers: {
|
||||
@@ -137,5 +137,6 @@ async function sendPushNotification({
|
||||
}),
|
||||
},
|
||||
);
|
||||
console.log(response);
|
||||
const postData = await response.json();
|
||||
console.log(postData);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
import React, {useEffect, useRef, useState} from 'react';
|
||||
import {AppState, PermissionsAndroid, Platform, View} from 'react-native';
|
||||
import {Notifications} from 'react-native-notifications';
|
||||
import {getBoltzWsUrl} from '../app/functions/boltz/boltzEndpoitns';
|
||||
import WebView from 'react-native-webview';
|
||||
import handleReverseClaimWSS from '../app/functions/boltz/handle-reverse-claim-wss';
|
||||
import handleWebviewClaimMessage from '../app/functions/boltz/handle-webview-claim-message';
|
||||
import {
|
||||
getLocalStorageItem,
|
||||
retrieveData,
|
||||
setLocalStorageItem,
|
||||
} from '../app/functions';
|
||||
|
||||
import {addDataToCollection} from '../db';
|
||||
|
||||
const PushNotificationManager = ({children}) => {
|
||||
// const isInitialRender = useRef(true);
|
||||
const webViewRef = useRef(null);
|
||||
const [webViewArgs, setWebViewArgs] = useState({
|
||||
page: null,
|
||||
function: null,
|
||||
});
|
||||
const receivedSwapsRef = useRef({});
|
||||
|
||||
useEffect(() => {
|
||||
async function initNotification() {
|
||||
requestAndroidNotificationsPermissinos();
|
||||
// if (Platform.OS === 'android') {
|
||||
// const hasPermission = await requestAndroidNotificationsPermissinos();
|
||||
// if (!hasPermission) {
|
||||
// console.log('Notification permission denied');
|
||||
// return;
|
||||
// } else {
|
||||
// getFcmToken();
|
||||
// }
|
||||
// }
|
||||
|
||||
if (Platform.OS === 'ios') Notifications.ios.setBadgeCount(0);
|
||||
|
||||
const registerDevice = async () => {
|
||||
Notifications.registerRemoteNotifications();
|
||||
Notifications.setNotificationChannel({
|
||||
channelId: 'blitzWallet',
|
||||
name: 'Blitz Wallet',
|
||||
importance: 5,
|
||||
description: 'Blitz Wallet notification',
|
||||
enableLights: true,
|
||||
showBadge: true,
|
||||
vibrationPattern: [200, 1000, 500, 1000, 500],
|
||||
});
|
||||
|
||||
Notifications.events().registerRemoteNotificationsRegistered(
|
||||
async event => {
|
||||
const deviceToken = event.deviceToken;
|
||||
console.log('Device Token Received', deviceToken);
|
||||
|
||||
const savedDeviceToken =
|
||||
JSON.parse(await getLocalStorageItem('pushToken')) || {};
|
||||
|
||||
const encriptedText = savedDeviceToken.encriptedText;
|
||||
|
||||
if (Object.keys(savedDeviceToken) === 0) {
|
||||
savePushNotificationToDatabase(deviceToken);
|
||||
return;
|
||||
}
|
||||
|
||||
const decriptedToken = await (
|
||||
await fetch(
|
||||
'https://blitz-wallet.com/.netlify/functions/decriptMessage',
|
||||
{
|
||||
method: 'POST', // Specify the HTTP method
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Set the content type to JSON
|
||||
},
|
||||
body: JSON.stringify({
|
||||
encriptedText, // The text property in the body
|
||||
}),
|
||||
},
|
||||
)
|
||||
).json();
|
||||
|
||||
if (decriptedToken.decryptedText === deviceToken) return;
|
||||
|
||||
savePushNotificationToDatabase(deviceToken);
|
||||
},
|
||||
);
|
||||
Notifications.events().registerRemoteNotificationsRegistrationFailed(
|
||||
event => {
|
||||
console.error('event-err', event);
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const savePushNotificationToDatabase = async pushKey => {
|
||||
try {
|
||||
const em = await (
|
||||
await fetch(
|
||||
'https://blitz-wallet.com/.netlify/functions/encriptMessage',
|
||||
{
|
||||
method: 'POST', // Specify the HTTP method
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Set the content type to JSON
|
||||
},
|
||||
body: JSON.stringify({
|
||||
text: pushKey, // The text property in the body
|
||||
}),
|
||||
},
|
||||
)
|
||||
).json();
|
||||
setLocalStorageItem('pushToken', JSON.stringify(em));
|
||||
addDataToCollection(
|
||||
{
|
||||
pushNotifications: {platform: Platform.OS, key: em},
|
||||
},
|
||||
'blitzWalletUsers',
|
||||
);
|
||||
} catch (err) {
|
||||
console.log(`Saving push notification to database error:`, err);
|
||||
}
|
||||
};
|
||||
|
||||
const registerNotificationEvents = () => {
|
||||
Notifications.events().registerNotificationReceivedForeground(
|
||||
(notification, completion) => {
|
||||
console.log('Notification Received - Foreground', notification);
|
||||
// handleSwap(notification, 'Foreground');
|
||||
completion({alert: true, sound: false, badge: false});
|
||||
},
|
||||
);
|
||||
|
||||
Notifications.events().registerNotificationOpened(
|
||||
(notification, completion) => {
|
||||
console.log('Notification opened by device user', notification);
|
||||
// /if (notification) handleSwap(notification, 'clicked');
|
||||
completion();
|
||||
},
|
||||
);
|
||||
|
||||
Notifications.events().registerNotificationReceivedBackground(
|
||||
(notification, completion) => {
|
||||
console.log('Notification Received - Background', notification);
|
||||
// handleSwap(notification, 'Background');
|
||||
completion({alert: true, sound: true, badge: false});
|
||||
},
|
||||
);
|
||||
|
||||
Notifications.getInitialNotification()
|
||||
.then(notification => {
|
||||
console.log('Initial notification was:', notification || 'N/A');
|
||||
// if (notification) handleSwap(notification, 'initialNotification');
|
||||
})
|
||||
.catch(err => console.error('getInitialNotification() failed', err));
|
||||
};
|
||||
registerNotificationEvents();
|
||||
registerDevice();
|
||||
}
|
||||
initNotification();
|
||||
}, []);
|
||||
|
||||
const handleSwap = (notification, notificationType) => {
|
||||
const webSocket = new WebSocket(
|
||||
`${getBoltzWsUrl(process.env.BOLTZ_ENVIRONMENT)}`,
|
||||
);
|
||||
|
||||
if (Platform.OS === 'ios') {
|
||||
const {
|
||||
payload: {privateKey, preimage, swapInfo, liquidAddress, title},
|
||||
} = notification;
|
||||
|
||||
if (
|
||||
title === 'Running in the background' ||
|
||||
title === 'Claiming incoming payment' ||
|
||||
title === 'Payment Received' ||
|
||||
!privateKey ||
|
||||
!preimage ||
|
||||
!swapInfo ||
|
||||
!liquidAddress
|
||||
)
|
||||
return;
|
||||
|
||||
if (!receivedSwapsRef.current[swapInfo.id]) {
|
||||
receivedSwapsRef.current[swapInfo.id] = true;
|
||||
} else return;
|
||||
|
||||
console.log(privateKey);
|
||||
console.log(preimage);
|
||||
console.log(swapInfo);
|
||||
console.log(liquidAddress);
|
||||
|
||||
setWebViewArgs({page: 'notifications'});
|
||||
if (notificationType === 'Background') {
|
||||
Notifications.postLocalNotification({
|
||||
title: 'Running in the background',
|
||||
});
|
||||
}
|
||||
Notifications.postLocalNotification({
|
||||
title: 'Claiming incoming payment',
|
||||
});
|
||||
|
||||
handleReverseClaimWSS({
|
||||
ref: webViewRef,
|
||||
webSocket,
|
||||
liquidAddress,
|
||||
swapInfo,
|
||||
preimage,
|
||||
privateKey: privateKey,
|
||||
fromPage: 'notifications',
|
||||
});
|
||||
|
||||
// Calling completion on iOS with `alert: true` will present the native iOS inApp notification.
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<WebView
|
||||
domStorageEnabled
|
||||
javaScriptEnabled
|
||||
ref={webViewRef}
|
||||
containerStyle={{position: 'absolute', top: 1000, left: 1000}}
|
||||
source={
|
||||
Platform.OS === 'ios'
|
||||
? require('boltz-swap-web-context')
|
||||
: {uri: 'file:///android_asset/boltzSwap.html'}
|
||||
}
|
||||
originWhitelist={['*']}
|
||||
onMessage={event =>
|
||||
handleWebviewClaimMessage(
|
||||
null,
|
||||
event,
|
||||
webViewArgs.page,
|
||||
webViewArgs.function,
|
||||
)
|
||||
}
|
||||
/>
|
||||
{children}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const requestAndroidNotificationsPermissinos = async () => {
|
||||
const granted = await PermissionsAndroid.request(
|
||||
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
|
||||
{
|
||||
title: 'Notification Permission',
|
||||
message:
|
||||
'Blitz Wallet needs access to send you notifications about transactions.',
|
||||
buttonNeutral: 'Ask Me Later',
|
||||
buttonNegative: 'Cancel',
|
||||
buttonPositive: 'OK',
|
||||
},
|
||||
);
|
||||
console.log(granted, 'TES');
|
||||
return granted === PermissionsAndroid.RESULTS.GRANTED;
|
||||
};
|
||||
|
||||
export default PushNotificationManager;
|
||||
@@ -1,6 +1,12 @@
|
||||
import React, {useEffect, useRef, useState} from 'react';
|
||||
import {AppState, PermissionsAndroid, Platform, View} from 'react-native';
|
||||
import {Notifications} from 'react-native-notifications';
|
||||
import {
|
||||
Alert,
|
||||
AppState,
|
||||
PermissionsAndroid,
|
||||
Platform,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import * as Notifications from 'expo-notifications';
|
||||
import {getBoltzWsUrl} from '../app/functions/boltz/boltzEndpoitns';
|
||||
import WebView from 'react-native-webview';
|
||||
import handleReverseClaimWSS from '../app/functions/boltz/handle-reverse-claim-wss';
|
||||
@@ -10,11 +16,10 @@ import {
|
||||
retrieveData,
|
||||
setLocalStorageItem,
|
||||
} from '../app/functions';
|
||||
|
||||
import {addDataToCollection} from '../db';
|
||||
import * as Device from 'expo-device';
|
||||
|
||||
const PushNotificationManager = ({children}) => {
|
||||
// const isInitialRender = useRef(true);
|
||||
const webViewRef = useRef(null);
|
||||
const [webViewArgs, setWebViewArgs] = useState({
|
||||
page: null,
|
||||
@@ -24,139 +29,96 @@ const PushNotificationManager = ({children}) => {
|
||||
|
||||
useEffect(() => {
|
||||
async function initNotification() {
|
||||
// if (Platform.OS === 'android') {
|
||||
// const hasPermission = await requestAndroidNotificationsPermissinos();
|
||||
// if (!hasPermission) {
|
||||
// console.log('Notification permission denied');
|
||||
// return;
|
||||
// } else {
|
||||
// getFcmToken();
|
||||
// }
|
||||
// }
|
||||
const {status} = await Notifications.requestPermissionsAsync();
|
||||
if (status !== 'granted') {
|
||||
console.log('Notification permission denied');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Platform.OS === 'ios') Notifications.ios.setBadgeCount(0);
|
||||
if (Platform.OS === 'ios') Notifications.setBadgeCountAsync(0);
|
||||
|
||||
const registerDevice = async () => {
|
||||
Notifications.registerRemoteNotifications();
|
||||
Notifications.setNotificationChannel({
|
||||
channelId: 'blitzWallet',
|
||||
name: 'Blitz Wallet',
|
||||
importance: 5,
|
||||
description: 'Blitz Wallet notification',
|
||||
enableLights: true,
|
||||
showBadge: true,
|
||||
vibrationPattern: [200, 1000, 500, 1000, 500],
|
||||
});
|
||||
const deviceToken = await registerForPushNotificationsAsync();
|
||||
if (deviceToken) {
|
||||
await checkAndSavePushNotificationToDatabase(deviceToken);
|
||||
}
|
||||
|
||||
Notifications.events().registerRemoteNotificationsRegistered(
|
||||
async event => {
|
||||
const deviceToken = event.deviceToken;
|
||||
console.log('Device Token Received', deviceToken);
|
||||
|
||||
const savedDeviceToken =
|
||||
JSON.parse(await getLocalStorageItem('pushToken')) || {};
|
||||
|
||||
const encriptedText = savedDeviceToken.encriptedText;
|
||||
|
||||
if (Object.keys(savedDeviceToken) === 0) {
|
||||
savePushNotificationToDatabase(deviceToken);
|
||||
return;
|
||||
}
|
||||
|
||||
const decriptedToken = await (
|
||||
await fetch(
|
||||
'https://blitz-wallet.com/.netlify/functions/decriptMessage',
|
||||
{
|
||||
method: 'POST', // Specify the HTTP method
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Set the content type to JSON
|
||||
},
|
||||
body: JSON.stringify({
|
||||
encriptedText, // The text property in the body
|
||||
}),
|
||||
},
|
||||
)
|
||||
).json();
|
||||
|
||||
if (decriptedToken.decryptedText === deviceToken) return;
|
||||
|
||||
savePushNotificationToDatabase(deviceToken);
|
||||
},
|
||||
);
|
||||
Notifications.events().registerRemoteNotificationsRegistrationFailed(
|
||||
event => {
|
||||
console.error('event-err', event);
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const savePushNotificationToDatabase = async pushKey => {
|
||||
try {
|
||||
const em = await (
|
||||
await fetch(
|
||||
'https://blitz-wallet.com/.netlify/functions/encriptMessage',
|
||||
{
|
||||
method: 'POST', // Specify the HTTP method
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Set the content type to JSON
|
||||
},
|
||||
body: JSON.stringify({
|
||||
text: pushKey, // The text property in the body
|
||||
}),
|
||||
},
|
||||
)
|
||||
).json();
|
||||
setLocalStorageItem('pushToken', JSON.stringify(em));
|
||||
addDataToCollection(
|
||||
{
|
||||
pushNotifications: {platform: Platform.OS, key: em},
|
||||
},
|
||||
'blitzWalletUsers',
|
||||
);
|
||||
} catch (err) {
|
||||
console.log(`Saving push notification to database error:`, err);
|
||||
}
|
||||
};
|
||||
|
||||
const registerNotificationEvents = () => {
|
||||
Notifications.events().registerNotificationReceivedForeground(
|
||||
(notification, completion) => {
|
||||
console.log('Notification Received - Foreground', notification);
|
||||
// handleSwap(notification, 'Foreground');
|
||||
completion({alert: true, sound: false, badge: false});
|
||||
},
|
||||
);
|
||||
|
||||
Notifications.events().registerNotificationOpened(
|
||||
(notification, completion) => {
|
||||
console.log('Notification opened by device user', notification);
|
||||
// /if (notification) handleSwap(notification, 'clicked');
|
||||
completion();
|
||||
},
|
||||
);
|
||||
|
||||
Notifications.events().registerNotificationReceivedBackground(
|
||||
(notification, completion) => {
|
||||
console.log('Notification Received - Background', notification);
|
||||
// handleSwap(notification, 'Background');
|
||||
completion({alert: true, sound: true, badge: false});
|
||||
},
|
||||
);
|
||||
|
||||
Notifications.getInitialNotification()
|
||||
.then(notification => {
|
||||
console.log('Initial notification was:', notification || 'N/A');
|
||||
// if (notification) handleSwap(notification, 'initialNotification');
|
||||
})
|
||||
.catch(err => console.error('getInitialNotification() failed', err));
|
||||
};
|
||||
registerNotificationEvents();
|
||||
if (AppState.currentState === 'background') return;
|
||||
registerDevice();
|
||||
registerNotificationHandlers();
|
||||
}
|
||||
initNotification();
|
||||
}, []);
|
||||
|
||||
const checkAndSavePushNotificationToDatabase = async deviceToken => {
|
||||
try {
|
||||
const savedDeviceToken =
|
||||
JSON.parse(await getLocalStorageItem('pushToken')) || {};
|
||||
|
||||
const test = await getLocalStorageItem('pushToken');
|
||||
const encryptedText = savedDeviceToken.encriptedText;
|
||||
|
||||
if (!Object.keys(savedDeviceToken).length) {
|
||||
savePushNotificationToDatabase(deviceToken);
|
||||
return;
|
||||
}
|
||||
|
||||
const decryptedToken = await (
|
||||
await fetch(
|
||||
'https://blitz-wallet.com/.netlify/functions/decriptMessage',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({encriptedText: encryptedText}),
|
||||
},
|
||||
)
|
||||
).json();
|
||||
|
||||
if (decryptedToken.decryptedText === deviceToken) return;
|
||||
|
||||
savePushNotificationToDatabase(deviceToken);
|
||||
} catch (error) {
|
||||
console.error('Error in checkAndSavePushNotificationToDatabase', error);
|
||||
}
|
||||
};
|
||||
|
||||
const savePushNotificationToDatabase = async pushKey => {
|
||||
try {
|
||||
const encryptedData = await (
|
||||
await fetch(
|
||||
`https://blitz-wallet.com/.netlify/functions/encriptMessage`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({text: pushKey}),
|
||||
},
|
||||
)
|
||||
).json();
|
||||
await setLocalStorageItem('pushToken', JSON.stringify(encryptedData));
|
||||
await addDataToCollection(
|
||||
{
|
||||
pushNotifications: {platform: Platform.OS, key: encryptedData},
|
||||
},
|
||||
'blitzWalletUsers',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error saving push notification to database', error);
|
||||
}
|
||||
};
|
||||
|
||||
const registerNotificationHandlers = () => {
|
||||
Notifications.addNotificationReceivedListener(notification => {
|
||||
console.log('Notification received in foreground', notification);
|
||||
Notifications.scheduleNotificationAsync({
|
||||
content: {title: 'Running in the background'},
|
||||
trigger: null,
|
||||
});
|
||||
// handleSwap(notification, 'Foreground');
|
||||
});
|
||||
|
||||
Notifications.addNotificationResponseReceivedListener(response => {
|
||||
console.log('Notification opened by device user', response.notification);
|
||||
// handleSwap(response.notification, 'Clicked');
|
||||
});
|
||||
};
|
||||
|
||||
const handleSwap = (notification, notificationType) => {
|
||||
const webSocket = new WebSocket(
|
||||
`${getBoltzWsUrl(process.env.BOLTZ_ENVIRONMENT)}`,
|
||||
@@ -165,7 +127,7 @@ const PushNotificationManager = ({children}) => {
|
||||
if (Platform.OS === 'ios') {
|
||||
const {
|
||||
payload: {privateKey, preimage, swapInfo, liquidAddress, title},
|
||||
} = notification;
|
||||
} = notification.request.content.data;
|
||||
|
||||
if (
|
||||
title === 'Running in the background' ||
|
||||
@@ -182,19 +144,20 @@ const PushNotificationManager = ({children}) => {
|
||||
receivedSwapsRef.current[swapInfo.id] = true;
|
||||
} else return;
|
||||
|
||||
console.log(privateKey);
|
||||
console.log(preimage);
|
||||
console.log(swapInfo);
|
||||
console.log(liquidAddress);
|
||||
console.log(privateKey, preimage, swapInfo, liquidAddress);
|
||||
|
||||
setWebViewArgs({page: 'notifications'});
|
||||
|
||||
if (notificationType === 'Background') {
|
||||
Notifications.postLocalNotification({
|
||||
title: 'Running in the background',
|
||||
Notifications.scheduleNotificationAsync({
|
||||
content: {title: 'Running in the background'},
|
||||
trigger: null,
|
||||
});
|
||||
}
|
||||
Notifications.postLocalNotification({
|
||||
title: 'Claiming incoming payment',
|
||||
|
||||
Notifications.scheduleNotificationAsync({
|
||||
content: {title: 'Claiming incoming payment'},
|
||||
trigger: null,
|
||||
});
|
||||
|
||||
handleReverseClaimWSS({
|
||||
@@ -206,8 +169,6 @@ const PushNotificationManager = ({children}) => {
|
||||
privateKey: privateKey,
|
||||
fromPage: 'notifications',
|
||||
});
|
||||
|
||||
// Calling completion on iOS with `alert: true` will present the native iOS inApp notification.
|
||||
}
|
||||
};
|
||||
|
||||
@@ -238,20 +199,48 @@ const PushNotificationManager = ({children}) => {
|
||||
);
|
||||
};
|
||||
|
||||
// const requestAndroidNotificationsPermissinos = async () => {
|
||||
// const granted = await PermissionsAndroid.request(
|
||||
// PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
|
||||
// {
|
||||
// title: 'Notification Permission',
|
||||
// message:
|
||||
// 'Blitz Wallet needs access to send you notifications about transactions.',
|
||||
// buttonNeutral: 'Ask Me Later',
|
||||
// buttonNegative: 'Cancel',
|
||||
// buttonPositive: 'OK',
|
||||
// },
|
||||
// );
|
||||
// console.log(granted, 'TES');
|
||||
// return granted === PermissionsAndroid.RESULTS.GRANTED;
|
||||
// };
|
||||
async function registerForPushNotificationsAsync() {
|
||||
let token;
|
||||
|
||||
if (Platform.OS === 'android') {
|
||||
await Notifications.setNotificationChannelAsync('default', {
|
||||
name: 'default',
|
||||
importance: Notifications.AndroidImportance.MAX,
|
||||
vibrationPattern: [0, 250, 250, 250],
|
||||
lightColor: '#FF231F7C',
|
||||
});
|
||||
}
|
||||
|
||||
if (Device.isDevice) {
|
||||
const {status: existingStatus} = await Notifications.getPermissionsAsync();
|
||||
let finalStatus = existingStatus;
|
||||
if (existingStatus !== 'granted') {
|
||||
const {status} = await Notifications.requestPermissionsAsync();
|
||||
finalStatus = status;
|
||||
}
|
||||
if (finalStatus !== 'granted') {
|
||||
Alert.alert('Failed to get push token for push notification!');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const projectId = 'edf13405-7014-4f88-aee5-ec131bfc217d';
|
||||
if (!projectId) {
|
||||
throw new Error('Project ID not found');
|
||||
}
|
||||
token = (
|
||||
await Notifications.getExpoPushTokenAsync({
|
||||
projectId,
|
||||
})
|
||||
).data;
|
||||
console.log(token, 'PUSH TOKEN');
|
||||
} catch (e) {
|
||||
token = `${e}`;
|
||||
}
|
||||
} else {
|
||||
Alert.alert('Must use physical device for Push Notifications');
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
export default PushNotificationManager;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#import "AppDelegate.h"
|
||||
#import "RNNotifications.h"
|
||||
// #import "RNNotifications.h"
|
||||
#import <React/RCTBundleURLProvider.h>
|
||||
#import <React/RCTLinkingManager.h>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// They will be passed down to the ViewController used by React Native.
|
||||
self.initialProps = @{};
|
||||
|
||||
[RNNotifications startMonitorNotifications]; // -> notifications
|
||||
// [RNNotifications startMonitorNotifications]; // -> notifications
|
||||
|
||||
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
||||
}
|
||||
@@ -31,17 +31,17 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
||||
[RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
||||
}
|
||||
// - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
||||
// [RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
||||
// }
|
||||
|
||||
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
|
||||
[RNNotifications didFailToRegisterForRemoteNotificationsWithError:error];
|
||||
}
|
||||
// - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
|
||||
// [RNNotifications didFailToRegisterForRemoteNotificationsWithError:error];
|
||||
// }
|
||||
|
||||
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
|
||||
[RNNotifications didReceiveBackgroundNotification:userInfo withCompletionHandler:completionHandler];
|
||||
}
|
||||
// - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
|
||||
// [RNNotifications didReceiveBackgroundNotification:userInfo withCompletionHandler:completionHandler];
|
||||
// }
|
||||
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
openURL:(NSURL *)url
|
||||
|
||||
@@ -4,6 +4,16 @@
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPIType</key>
|
||||
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
|
||||
<key>NSPrivacyAccessedAPITypeReasons</key>
|
||||
<array>
|
||||
<string>C617.1</string>
|
||||
<string>0A2A.1</string>
|
||||
<string>3B52.1</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPIType</key>
|
||||
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
|
||||
@@ -20,16 +30,6 @@
|
||||
<string>35F9.1</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPIType</key>
|
||||
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
|
||||
<key>NSPrivacyAccessedAPITypeReasons</key>
|
||||
<array>
|
||||
<string>0A2A.1</string>
|
||||
<string>3B52.1</string>
|
||||
<string>C617.1</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPIType</key>
|
||||
<string>NSPrivacyAccessedAPICategoryDiskSpace</string>
|
||||
|
||||
@@ -7,6 +7,10 @@ PODS:
|
||||
- BreezSDK (0.5.2):
|
||||
- breez_sdkFFI (= 0.5.2)
|
||||
- DoubleConversion (1.1.6)
|
||||
- EASClient (0.12.0):
|
||||
- ExpoModulesCore
|
||||
- EXApplication (5.9.1):
|
||||
- ExpoModulesCore
|
||||
- EXBarCodeScanner (13.0.1):
|
||||
- EXImageLoader
|
||||
- ExpoModulesCore
|
||||
@@ -17,6 +21,11 @@ PODS:
|
||||
- EXImageLoader (4.7.0):
|
||||
- ExpoModulesCore
|
||||
- React-Core
|
||||
- EXJSONUtils (0.13.1)
|
||||
- EXManifests (0.14.3):
|
||||
- ExpoModulesCore
|
||||
- EXNotifications (0.28.18):
|
||||
- ExpoModulesCore
|
||||
- Expo (51.0.32):
|
||||
- ExpoModulesCore
|
||||
- ExpoAsset (10.0.10):
|
||||
@@ -70,6 +79,37 @@ PODS:
|
||||
- ExpoModulesCore
|
||||
- ExpoWebBrowser (13.0.3):
|
||||
- ExpoModulesCore
|
||||
- EXStructuredHeaders (3.8.0)
|
||||
- EXUpdates (0.25.26):
|
||||
- DoubleConversion
|
||||
- EASClient
|
||||
- EXManifests
|
||||
- ExpoModulesCore
|
||||
- EXStructuredHeaders
|
||||
- EXUpdatesInterface
|
||||
- glog
|
||||
- hermes-engine
|
||||
- RCT-Folly (= 2024.01.01.00)
|
||||
- RCTRequired
|
||||
- RCTTypeSafety
|
||||
- ReachabilitySwift
|
||||
- React-Core
|
||||
- React-debug
|
||||
- React-Fabric
|
||||
- React-featureflags
|
||||
- React-graphics
|
||||
- React-ImageManager
|
||||
- React-NativeModulesApple
|
||||
- React-RCTFabric
|
||||
- React-rendererdebug
|
||||
- React-utils
|
||||
- ReactCodegen
|
||||
- ReactCommon/turbomodule/bridging
|
||||
- ReactCommon/turbomodule/core
|
||||
- "sqlite3 (~> 3.45.3+1)"
|
||||
- Yoga
|
||||
- EXUpdatesInterface (0.16.2):
|
||||
- ExpoModulesCore
|
||||
- FBLazyVector (0.75.2)
|
||||
- fmt (9.1.0)
|
||||
- glog (0.3.5)
|
||||
@@ -148,6 +188,7 @@ PODS:
|
||||
- FBLazyVector (= 0.75.2)
|
||||
- RCTRequired (= 0.75.2)
|
||||
- React-Core (= 0.75.2)
|
||||
- ReachabilitySwift (5.2.4)
|
||||
- React (0.75.2):
|
||||
- React-Core (= 0.75.2)
|
||||
- React-Core/DevSupport (= 0.75.2)
|
||||
@@ -1848,6 +1889,9 @@ PODS:
|
||||
- RNSVG (15.7.1):
|
||||
- React-Core
|
||||
- SocketRocket (0.7.0)
|
||||
- "sqlite3 (3.45.3+1)":
|
||||
- "sqlite3/common (= 3.45.3+1)"
|
||||
- "sqlite3/common (3.45.3+1)"
|
||||
- VisionCamera (4.5.3):
|
||||
- VisionCamera/Core (= 4.5.3)
|
||||
- VisionCamera/React (= 4.5.3)
|
||||
@@ -1865,9 +1909,14 @@ DEPENDENCIES:
|
||||
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
|
||||
- "breez_sdk (from `../node_modules/@breeztech/react-native-breez-sdk`)"
|
||||
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
|
||||
- EASClient (from `../node_modules/expo-eas-client/ios`)
|
||||
- EXApplication (from `../node_modules/expo-application/ios`)
|
||||
- EXBarCodeScanner (from `../node_modules/expo-barcode-scanner/ios`)
|
||||
- EXConstants (from `../node_modules/expo-constants/ios`)
|
||||
- EXImageLoader (from `../node_modules/expo-image-loader/ios`)
|
||||
- EXJSONUtils (from `../node_modules/expo-json-utils/ios`)
|
||||
- EXManifests (from `../node_modules/expo-manifests/ios`)
|
||||
- EXNotifications (from `../node_modules/expo-notifications/ios`)
|
||||
- Expo (from `../node_modules/expo`)
|
||||
- ExpoAsset (from `../node_modules/expo-asset/ios`)
|
||||
- ExpoCamera (from `../node_modules/expo-camera/ios`)
|
||||
@@ -1883,6 +1932,9 @@ DEPENDENCIES:
|
||||
- ExpoSecureStore (from `../node_modules/expo-secure-store/ios`)
|
||||
- ExpoSpeech (from `../node_modules/expo-speech/ios`)
|
||||
- ExpoWebBrowser (from `../node_modules/expo-web-browser/ios`)
|
||||
- EXStructuredHeaders (from `../node_modules/expo-structured-headers/ios`)
|
||||
- EXUpdates (from `../node_modules/expo-updates/ios`)
|
||||
- EXUpdatesInterface (from `../node_modules/expo-updates-interface/ios`)
|
||||
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
|
||||
- fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`)
|
||||
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
|
||||
@@ -1973,7 +2025,9 @@ SPEC REPOS:
|
||||
- lottie-ios
|
||||
- lwkFFI
|
||||
- OpenSSL-Universal
|
||||
- ReachabilitySwift
|
||||
- SocketRocket
|
||||
- sqlite3
|
||||
- ZXingObjC
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
@@ -1983,12 +2037,22 @@ EXTERNAL SOURCES:
|
||||
:path: "../node_modules/@breeztech/react-native-breez-sdk"
|
||||
DoubleConversion:
|
||||
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
|
||||
EASClient:
|
||||
:path: "../node_modules/expo-eas-client/ios"
|
||||
EXApplication:
|
||||
:path: "../node_modules/expo-application/ios"
|
||||
EXBarCodeScanner:
|
||||
:path: "../node_modules/expo-barcode-scanner/ios"
|
||||
EXConstants:
|
||||
:path: "../node_modules/expo-constants/ios"
|
||||
EXImageLoader:
|
||||
:path: "../node_modules/expo-image-loader/ios"
|
||||
EXJSONUtils:
|
||||
:path: "../node_modules/expo-json-utils/ios"
|
||||
EXManifests:
|
||||
:path: "../node_modules/expo-manifests/ios"
|
||||
EXNotifications:
|
||||
:path: "../node_modules/expo-notifications/ios"
|
||||
Expo:
|
||||
:path: "../node_modules/expo"
|
||||
ExpoAsset:
|
||||
@@ -2019,6 +2083,12 @@ EXTERNAL SOURCES:
|
||||
:path: "../node_modules/expo-speech/ios"
|
||||
ExpoWebBrowser:
|
||||
:path: "../node_modules/expo-web-browser/ios"
|
||||
EXStructuredHeaders:
|
||||
:path: "../node_modules/expo-structured-headers/ios"
|
||||
EXUpdates:
|
||||
:path: "../node_modules/expo-updates/ios"
|
||||
EXUpdatesInterface:
|
||||
:path: "../node_modules/expo-updates-interface/ios"
|
||||
FBLazyVector:
|
||||
:path: "../node_modules/react-native/Libraries/FBLazyVector"
|
||||
fmt:
|
||||
@@ -2185,9 +2255,14 @@ SPEC CHECKSUMS:
|
||||
breez_sdkFFI: 520cb4b36d3d7aec22823afd615dbb6159b3ee15
|
||||
BreezSDK: 8c7dca8b04c7e4f7132755f080ae077760f48341
|
||||
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
|
||||
EASClient: 1509a9a6b48b932ec61667644634daf2562983b8
|
||||
EXApplication: c08200c34daca7af7fd76ac4b9d606077410e8ad
|
||||
EXBarCodeScanner: e2dd9b42c1b522a2adc9202b1dfbc64cb34456d1
|
||||
EXConstants: 409690fbfd5afea964e5e9d6c4eb2c2b59222c59
|
||||
EXImageLoader: ab589d67d6c5f2c33572afea9917304418566334
|
||||
EXJSONUtils: 30c17fd9cc364d722c0946a550dfbf1be92ef6a4
|
||||
EXManifests: c1fab4c3237675e7b0299ea8df0bcb14baca4f42
|
||||
EXNotifications: dd289340c26bc5388e440fc90d0b2c661cbd0285
|
||||
Expo: 33132a667698a3259a4e6c0af1b4936388e5fa33
|
||||
ExpoAsset: 323700f291684f110fb55f0d4022a3362ea9f875
|
||||
ExpoCamera: 929be541d1c1319fcf32f9f5d9df8b97804346b5
|
||||
@@ -2203,6 +2278,9 @@ SPEC CHECKSUMS:
|
||||
ExpoSecureStore: 060cebcb956b80ddae09821610ac1aa9e1ac74cd
|
||||
ExpoSpeech: 258ea713923eb70ef63d3bdb14f47a462d0b6f0e
|
||||
ExpoWebBrowser: 7595ccac6938eb65b076385fd23d035db9ecdc8e
|
||||
EXStructuredHeaders: cb8d1f698e144f4c5547b4c4963e1552f5d2b457
|
||||
EXUpdates: 61e1a3414212263761b16731611cc174e3eda376
|
||||
EXUpdatesInterface: 996527fd7d1a5d271eb523258d603f8f92038f24
|
||||
FBLazyVector: 38bb611218305c3bc61803e287b8a81c6f63b619
|
||||
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
|
||||
glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
|
||||
@@ -2217,6 +2295,7 @@ SPEC CHECKSUMS:
|
||||
RCTDeprecation: 34cbf122b623037ea9facad2e92e53434c5c7422
|
||||
RCTRequired: 24c446d7bcd0f517d516b6265d8df04dc3eb1219
|
||||
RCTTypeSafety: ef5e91bd791abd3a99b2c75fd565791102a66352
|
||||
ReachabilitySwift: 32793e867593cfc1177f5d16491e3a197d2fccda
|
||||
React: 643f06bc294806d2db2526b424fdf759e107f514
|
||||
React-callinvoker: 34d1fa0c340104f324e2521f546196beb44dfad2
|
||||
React-Core: facd883836d8d1cc1949d2053c58eab5fb22eb75
|
||||
@@ -2285,6 +2364,7 @@ SPEC CHECKSUMS:
|
||||
RNScreens: 19719a9c326e925498ac3b2d35c4e50fe87afc06
|
||||
RNSVG: 4590aa95758149fa27c5c83e54a6a466349a1688
|
||||
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
|
||||
sqlite3: 02d1f07eaaa01f80a1c16b4b31dfcbb3345ee01a
|
||||
VisionCamera: cb84d0d8485b3e67c91b62931d3aa88f49747c92
|
||||
Yoga: a1d7895431387402a674fd0d1c04ec85e87909b8
|
||||
ZXingObjC: 8898711ab495761b2dbbdec76d90164a6d7e14c5
|
||||
|
||||
Reference in New Issue
Block a user