Merge pull request #2393 from BlueWallet/push

ADD: Fetch txs when Push is received (Android)
This commit is contained in:
GLaDOS 2020-12-23 19:06:57 +00:00 committed by GitHub
commit 099b794c7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 27 deletions

24
App.js
View File

@ -153,7 +153,6 @@ const App = () => {
const notifications2process = await Notifications.getStoredNotifications();
for (const payload of notifications2process) {
const wasTapped = payload.foreground === false || (payload.foreground === true && payload.userInteraction === true);
if (!wasTapped) continue;
console.log('processing push notification:', payload);
let wallet;
@ -171,16 +170,19 @@ const App = () => {
if (wallet) {
const walletID = wallet.getID();
fetchAndSaveWalletTransactions(walletID);
NavigationService.dispatch(
CommonActions.navigate({
name: 'WalletTransactions',
key: `WalletTransactions-${wallet.getID()}`,
params: {
walletID,
walletType: wallet.type,
},
}),
);
if (wasTapped) {
NavigationService.dispatch(
CommonActions.navigate({
name: 'WalletTransactions',
key: `WalletTransactions-${wallet.getID()}`,
params: {
walletID,
walletType: wallet.type,
},
}),
);
}
// no delay (1ms) as we dont need to wait for transaction propagation. 500ms is a delay to wait for the navigation
await Notifications.clearStoredNotifications();
return true;

View File

@ -1,5 +1,5 @@
import PushNotificationIOS from '@react-native-community/push-notification-ios';
import { Alert, Platform } from 'react-native';
import { Alert } from 'react-native';
import Frisbee from 'frisbee';
import { getApplicationName, getVersion, getSystemName, getSystemVersion } from 'react-native-device-info';
import AsyncStorage from '@react-native-async-storage/async-storage';
@ -54,14 +54,7 @@ function Notifications(props) {
//
// ...we save notification in internal notifications queue thats gona be processed later (on unsuspend with decrypted storage)
if (Platform.OS === 'ios' && notification.foreground === true && notification.userInteraction === false) {
// iOS hack
// @see https://github.com/zo0r/react-native-push-notification/issues/1585
notification.userInteraction = true;
// also, on iOS app is not suspending/unsuspending when user taps a notification bubble,so we simulate it
// since its where we actually handle notifications:
setTimeout(() => props.onProcessNotifications(), 500);
}
setTimeout(() => props.onProcessNotifications(), 500);
let notifications = [];
try {

View File

@ -145,7 +145,7 @@
<key>NSCalendarsUsageDescription</key>
<string>This alert should not show up as we do not require this data</string>
<key>NSCameraUsageDescription</key>
<string>In order to quickly scan the recipient&apos;s address, we need your permission to use the camera to scan their QR Code.</string>
<string>In order to quickly scan the recipient's address, we need your permission to use the camera to scan their QR Code.</string>
<key>NSFaceIDUsageDescription</key>
<string>In order to use FaceID please confirm your permission.</string>
<key>NSLocationAlwaysUsageDescription</key>
@ -186,6 +186,8 @@
</array>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>processing</string>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>

View File

@ -355,7 +355,7 @@ PODS:
- React-Core
- RNCMaskedView (0.1.10):
- React
- RNCPushNotificationIOS (1.7.1):
- RNCPushNotificationIOS (1.8.0):
- React-Core
- RNDefaultPreference (1.4.3):
- React
@ -727,7 +727,7 @@ SPEC CHECKSUMS:
RNCAsyncStorage: bc2f81cc1df90c267ce9ed30bb2dbc93b945a8ee
RNCClipboard: 8f9f12fabf3c06e976f19f87a62c89e28dfedfca
RNCMaskedView: f5c7d14d6847b7b44853f7acb6284c1da30a3459
RNCPushNotificationIOS: eaf01f848a0b872b194d31bcad94bb864299e01e
RNCPushNotificationIOS: 5b1cf9ad2aaa107ecb92d5d2d7005ba521b2b97a
RNDefaultPreference: 21816c0a6f61a2829ccc0cef034392e9b509ee5f
RNDeviceInfo: 57bb2806fb7bd982a1434e9f0b4e6a6ab1f6702e
RNFS: 2bd9eb49dc82fa9676382f0585b992c424cd59df

6
package-lock.json generated
View File

@ -6392,9 +6392,9 @@
"integrity": "sha512-rk4sWFsmtOw8oyx8SD3KSvawwaK7gRBSEIy2TAwURyGt+3TizssXP1r8nx3zY+R7v2vYYHXZ+k2/GULAT/bcaQ=="
},
"@react-native-community/push-notification-ios": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/@react-native-community/push-notification-ios/-/push-notification-ios-1.7.1.tgz",
"integrity": "sha512-cx535+qyGbGTkx5GEHcF+Yd3fT9k1L114VeqQ5hkDYwU8unkKAiItjQz7Utvj/mcffwhqvPFU2FI3eKM3R1VYw==",
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/@react-native-community/push-notification-ios/-/push-notification-ios-1.8.0.tgz",
"integrity": "sha512-vxvkeampafjmtDoQBN8Q4azP21l6cMX93+OQZemyIWZmG++OjCVDQVitobf/kWLm5zyGwdylejbpMGo75qo7rA==",
"requires": {
"invariant": "^2.2.4"
}

View File

@ -71,7 +71,7 @@
"@react-native-community/clipboard": "1.5.0",
"@react-native-community/geolocation": "2.0.2",
"@react-native-community/masked-view": "0.1.10",
"@react-native-community/push-notification-ios": "1.7.1",
"@react-native-community/push-notification-ios": "1.8.0",
"@react-native-community/slider": "3.0.3",
"@react-navigation/drawer": "5.11.2",
"@react-navigation/native": "5.8.9",