Skip to content

Commit b6d2197

Browse files
authored
Merge pull request Expensify#14579 from Expensify/Rory-PushNotificationOptInStatus
Track Push Notification Opt-In Status
2 parents 9d5d102 + 5af1d26 commit b6d2197

23 files changed

Lines changed: 311 additions & 30 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import MockDeviceInfo from 'react-native-device-info/jest/react-native-device-info-mock';
2+
3+
export default MockDeviceInfo;

__mocks__/urbanairship-react-native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const UrbanAirship = {
2121
removeAllListeners: jest.fn(),
2222
setBadgeNumber: jest.fn(),
2323
setForegroundPresentationOptions: jest.fn(),
24+
getNotificationStatus: () => Promise.resolve({airshipOptIn: false, systemEnabled: false}),
2425
};
2526

2627
export default UrbanAirship;

android/app/src/main/java/com/expensify/chat/customairshipextender/CustomNotificationProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import java.util.concurrent.TimeUnit;
4646

4747
public class CustomNotificationProvider extends ReactNotificationProvider {
48-
4948
// Resize icons to 100 dp x 100 dp
5049
private static final int MAX_ICON_SIZE_DPS = 100;
5150

desktop/ELECTRON_EVENTS.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
const ELECTRON_EVENTS = {
2+
BLUR: 'blur',
3+
FOCUS: 'focus',
4+
LOCALE_UPDATED: 'locale-updated',
5+
REQUEST_DEVICE_ID: 'requestDeviceID',
6+
REQUEST_FOCUS_APP: 'requestFocusApp',
27
REQUEST_UPDATE_BADGE_COUNT: 'requestUpdateBadgeCount',
38
REQUEST_VISIBILITY: 'requestVisibility',
4-
REQUEST_FOCUS_APP: 'requestFocusApp',
59
SHOW_KEYBOARD_SHORTCUTS_MODAL: 'show-keyboard-shortcuts-modal',
610
START_UPDATE: 'start-update',
711
UPDATE_DOWNLOADED: 'update-downloaded',
8-
FOCUS: 'focus',
9-
BLUR: 'blur',
10-
LOCALE_UPDATED: 'locale-updated',
1112
};
1213

1314
module.exports = ELECTRON_EVENTS;

desktop/contextBridge.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
const ELECTRON_EVENTS = require('./ELECTRON_EVENTS');
77

88
const WHITELIST_CHANNELS_RENDERER_TO_MAIN = [
9+
ELECTRON_EVENTS.REQUEST_DEVICE_ID,
910
ELECTRON_EVENTS.REQUEST_FOCUS_APP,
1011
ELECTRON_EVENTS.REQUEST_UPDATE_BADGE_COUNT,
1112
ELECTRON_EVENTS.REQUEST_VISIBILITY,
@@ -59,6 +60,21 @@ contextBridge.exposeInMainWorld('electron', {
5960
return ipcRenderer.sendSync(channel, data);
6061
},
6162

63+
/**
64+
* Execute a function in the main process and return a promise that resolves with its response.
65+
*
66+
* @param {String} channel
67+
* @param {*} args
68+
* @returns {Promise}
69+
*/
70+
invoke: (channel, ...args) => {
71+
if (!_.contains(WHITELIST_CHANNELS_RENDERER_TO_MAIN, channel)) {
72+
throw new Error(getErrorMessage(channel));
73+
}
74+
75+
return ipcRenderer.invoke(channel, ...args);
76+
},
77+
6278
/**
6379
* Set up a listener for events emitted from the main process and sent to the renderer process.
6480
*

desktop/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const serve = require('electron-serve');
1212
const contextMenu = require('electron-context-menu');
1313
const {autoUpdater} = require('electron-updater');
1414
const log = require('electron-log');
15+
const {machineId} = require('node-machine-id');
1516
const ELECTRON_EVENTS = require('./ELECTRON_EVENTS');
1617
const checkForUpdates = require('../src/libs/checkForUpdates');
1718
const CONFIG = require('../src/CONFIG').default;
@@ -282,6 +283,8 @@ const mainWindow = (() => {
282283
titleBarStyle: 'hidden',
283284
});
284285

286+
ipcMain.handle(ELECTRON_EVENTS.REQUEST_DEVICE_ID, () => machineId());
287+
285288
/*
286289
* The default origin of our Electron app is app://- instead of https://new.expensify.com or https://staging.new.expensify.com
287290
* This causes CORS errors because the referer and origin headers are wrong and the API responds with an Access-Control-Allow-Origin that doesn't match app://-

desktop/package-lock.json

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

desktop/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"electron-context-menu": "^2.3.0",
88
"electron-log": "^4.4.7",
99
"electron-serve": "^1.0.0",
10-
"electron-updater": "^4.3.4"
10+
"electron-updater": "^4.3.4",
11+
"node-machine-id": "^1.1.12"
1112
},
1213
"author": "Expensify, Inc.",
1314
"license": "MIT",

ios/Podfile.lock

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
PODS:
2-
- Airship (16.8.0):
3-
- Airship/Automation (= 16.8.0)
4-
- Airship/Basement (= 16.8.0)
5-
- Airship/Core (= 16.8.0)
6-
- Airship/ExtendedActions (= 16.8.0)
7-
- Airship/MessageCenter (= 16.8.0)
8-
- Airship/Automation (16.8.0):
2+
- Airship (16.10.7):
3+
- Airship/Automation (= 16.10.7)
4+
- Airship/Basement (= 16.10.7)
5+
- Airship/Core (= 16.10.7)
6+
- Airship/ExtendedActions (= 16.10.7)
7+
- Airship/MessageCenter (= 16.10.7)
8+
- Airship/Automation (16.10.7):
99
- Airship/Core
10-
- Airship/Basement (16.8.0)
11-
- Airship/Core (16.8.0):
10+
- Airship/Basement (16.10.7)
11+
- Airship/Core (16.10.7):
1212
- Airship/Basement
13-
- Airship/ExtendedActions (16.8.0):
13+
- Airship/ExtendedActions (16.10.7):
1414
- Airship/Core
15-
- Airship/MessageCenter (16.8.0):
15+
- Airship/MessageCenter (16.10.7):
1616
- Airship/Core
1717
- boost (1.76.0)
1818
- CocoaAsyncSocket (7.6.5)
@@ -575,6 +575,8 @@ PODS:
575575
- React-Core
576576
- RNDateTimePicker (3.5.2):
577577
- React-Core
578+
- RNDeviceInfo (10.3.0):
579+
- React-Core
578580
- RNFastImage (8.6.3):
579581
- React-Core
580582
- SDWebImage (~> 5.11.1)
@@ -639,8 +641,8 @@ PODS:
639641
- libwebp (~> 1.0)
640642
- SDWebImage/Core (~> 5.10)
641643
- SocketRocket (0.6.0)
642-
- urbanairship-react-native (14.4.1):
643-
- Airship (= 16.8.0)
644+
- urbanairship-react-native (14.6.1):
645+
- Airship (= 16.10.7)
644646
- React-Core
645647
- Yoga (1.14.0)
646648
- YogaKit (1.18.1):
@@ -730,6 +732,7 @@ DEPENDENCIES:
730732
- "RNCClipboard (from `../node_modules/@react-native-community/clipboard`)"
731733
- "RNCPicker (from `../node_modules/@react-native-picker/picker`)"
732734
- "RNDateTimePicker (from `../node_modules/@react-native-community/datetimepicker`)"
735+
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
733736
- RNFastImage (from `../node_modules/react-native-fast-image`)
734737
- "RNFBAnalytics (from `../node_modules/@react-native-firebase/analytics`)"
735738
- "RNFBApp (from `../node_modules/@react-native-firebase/app`)"
@@ -901,6 +904,8 @@ EXTERNAL SOURCES:
901904
:path: "../node_modules/@react-native-picker/picker"
902905
RNDateTimePicker:
903906
:path: "../node_modules/@react-native-community/datetimepicker"
907+
RNDeviceInfo:
908+
:path: "../node_modules/react-native-device-info"
904909
RNFastImage:
905910
:path: "../node_modules/react-native-fast-image"
906911
RNFBAnalytics:
@@ -929,7 +934,7 @@ EXTERNAL SOURCES:
929934
:path: "../node_modules/react-native/ReactCommon/yoga"
930935

931936
SPEC CHECKSUMS:
932-
Airship: 4657c3d5118441240e04674d9445cbd6e363c956
937+
Airship: fbff646723323c58e3871cd30488612ca373f597
933938
boost: a7c83b31436843459a1961bfd74b96033dc77234
934939
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
935940
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
@@ -1019,6 +1024,7 @@ SPEC CHECKSUMS:
10191024
RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495
10201025
RNCPicker: 0b65be85fe7954fbb2062ef079e3d1cde252d888
10211026
RNDateTimePicker: 7658208086d86d09e1627b5c34ba0cf237c60140
1027+
RNDeviceInfo: 4701f0bf2a06b34654745053db0ce4cb0c53ada7
10221028
RNFastImage: 5c9c9fed9c076e521b3f509fe79e790418a544e8
10231029
RNFBAnalytics: f76bfa164ac235b00505deb9fc1776634056898c
10241030
RNFBApp: 729c0666395b1953198dc4a1ec6deb8fbe1c302e
@@ -1033,7 +1039,7 @@ SPEC CHECKSUMS:
10331039
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
10341040
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
10351041
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
1036-
urbanairship-react-native: 7e2e9a84c541b1d04798e51f7f390a2d5806eac0
1042+
urbanairship-react-native: fe4d169332546a0efd348a009aa490dc36ff815e
10371043
Yoga: f77f6497bccebdcbc8efb03dbf83eadfdec6d104
10381044
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
10391045

package-lock.json

Lines changed: 22 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)