Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local notifications on iOS and Android #3024

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
055eab1
Update urban airship to 11.0.0
roryabraham Apr 27, 2021
e57688b
Setup draft local push notification implementation
roryabraham May 20, 2021
e5a366c
Rename getReportActionNotificationPayload
roryabraham May 20, 2021
2128f87
Update processQueue JSDoc
roryabraham May 20, 2021
4ecd1e6
Add a comment explaining why a queue is needed
roryabraham May 20, 2021
156d31f
Add throws to JSDocs
roryabraham May 20, 2021
f713844
Create cross-platform LocalNotificationService lib
roryabraham May 20, 2021
88fb013
DRY up common notifications between platforms
roryabraham May 20, 2021
7c5b2a2
Merge branch 'main' into Rory-BackgroundPushNotifications
roryabraham Jun 1, 2021
df0bfac
Reinstall node modules and pods after bad merge
roryabraham Jun 1, 2021
1453ce8
Fix AppDelegate
roryabraham Jun 1, 2021
1556181
Fix export and implement isVisible on mobile
roryabraham Jun 2, 2021
9757797
Merge branch 'main' into Rory-BackgroundPushNotifications
roryabraham Jun 18, 2021
f0d5525
Reinstall everything after merge
roryabraham Jun 18, 2021
a40503a
Get onNotification callback working
roryabraham Jun 18, 2021
441db41
Save draft state for debugging
roryabraham Jun 23, 2021
a2d6937
Fix registration callback promise
roryabraham Jun 29, 2021
e853716
Merge branch 'main' into Rory-BackgroundPushNotifications
roryabraham Jun 29, 2021
d7ed1ef
Remove debug logs
roryabraham Jun 29, 2021
16d6783
Merge branch 'main' into Rory-BackgroundPushNotifications
roryabraham Jul 2, 2021
6bf9df6
Commit working draft to save for later
roryabraham Jul 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ android {
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
if (project.hasProperty('RORY_TEST_KEYSTORE_FILE')) {
storeFile file(RORY_TEST_KEYSTORE_FILE)
storePassword RORY_TEST_STORE_PASSWORD
keyAlias RORY_TEST_KEY_ALIAS
keyPassword RORY_TEST_KEY_PASSWORD
}
}
debug {
Expand Down Expand Up @@ -200,6 +200,10 @@ android {

}
}

lintOptions {
checkReleaseBuilds false
}
}

dependencies {
Expand Down
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:debuggable="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
6 changes: 4 additions & 2 deletions android/app/src/main/assets/airshipconfig.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
developmentAppKey = uulSSfTDQJ2r0PMpjRrhmQ
developmentAppSecret = D4Bhf0HrQEehrPua74Tyiw

productionAppKey = 55vypj0ARc6cN09MX7ogtQ
productionAppSecret = EsSaqbdLSvmyC6kSBFJCtQ
productionAppKey = uulSSfTDQJ2r0PMpjRrhmQ
productionAppSecret = D4Bhf0HrQEehrPua74Tyiw

logLevel = verbose

# Notification Customization
notificationIcon = ic_notification
Expand Down
260 changes: 130 additions & 130 deletions ios/ExpensifyCash.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions ios/ExpensifyCash/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "RNBootSplash.h"

#import <UserNotifications/UserNotifications.h>
#import <RNCPushNotificationIOS.h>

#ifdef FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
Expand Down Expand Up @@ -86,4 +87,36 @@ - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull N
restorationHandler:restorationHandler];
}

//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
}

/*=== START react-native-push-notification-ios configs ===*/
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
// Required for the registrationError event.
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
}
// Required for localNotification event
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler
{
[RNCPushNotificationIOS didReceiveNotificationResponse:response];
}
/*=== END react-native-push-notification-ios configs ===*/

@end
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ PODS:
- React-Core
- RNCPicker (1.9.11):
- React-Core
- RNCPushNotificationIOS (1.8.0):
- React-Core
- RNFBAnalytics (7.6.8):
- Firebase/Analytics (~> 6.34.0)
- React-Core
Expand Down Expand Up @@ -568,6 +570,7 @@ DEPENDENCIES:
- "RNCClipboard (from `../node_modules/@react-native-community/clipboard`)"
- "RNCMaskedView (from `../node_modules/@react-native-masked-view/masked-view`)"
- "RNCPicker (from `../node_modules/@react-native-picker/picker`)"
- "RNCPushNotificationIOS (from `../node_modules/@react-native-community/push-notification-ios`)"
- "RNFBAnalytics (from `../node_modules/@react-native-firebase/analytics`)"
- "RNFBApp (from `../node_modules/@react-native-firebase/app`)"
- "RNFBCrashlytics (from `../node_modules/@react-native-firebase/crashlytics`)"
Expand Down Expand Up @@ -701,6 +704,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@react-native-masked-view/masked-view"
RNCPicker:
:path: "../node_modules/@react-native-picker/picker"
RNCPushNotificationIOS:
:path: "../node_modules/@react-native-community/push-notification-ios"
RNFBAnalytics:
:path: "../node_modules/@react-native-firebase/analytics"
RNFBApp:
Expand Down Expand Up @@ -794,6 +799,7 @@ SPEC CHECKSUMS:
RNCClipboard: 5e299c6df8e0c98f3d7416b86ae563d3a9f768a3
RNCMaskedView: 138134c4d8a9421b4f2bf39055a79aa05c2d47b1
RNCPicker: 6780c753e9e674065db90d9c965920516402579d
RNCPushNotificationIOS: 5b1cf9ad2aaa107ecb92d5d2d7005ba521b2b97a
RNFBAnalytics: 2dc4dd9e2445faffca041b10447a23a71dcdabf8
RNFBApp: 7eacc7da7ab19f96c05e434017d44a9f09410da8
RNFBCrashlytics: 4870c14cf8833053b6b5648911abefe1923854d2
Expand Down
24 changes: 21 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@react-native-community/netinfo": "^5.9.10",
"@react-native-community/progress-bar-android": "^1.0.4",
"@react-native-community/progress-view": "^1.2.3",
"@react-native-community/push-notification-ios": "^1.8.0",
"@react-native-firebase/analytics": "^7.6.7",
"@react-native-firebase/app": "^8.4.5",
"@react-native-firebase/crashlytics": "^8.4.9",
Expand All @@ -62,6 +63,7 @@
"expensify-common": "git://github.com/Expensify/expensify-common.git#c3465bf615390a2844087ec7f2343b0607ea484c",
"file-loader": "^6.0.0",
"html-entities": "^1.3.1",
"ios-deploy": "^1.11.4",
"lodash": "4.17.21",
"metro-config": "^0.64.0",
"moment": "^2.27.0",
Expand All @@ -85,6 +87,7 @@
"react-native-permissions": "^3.0.1",
"react-native-picker-select": "8.0.4",
"react-native-plaid-link-sdk": "^7.0.5",
"react-native-push-notification": "^7.3.1",
"react-native-reanimated": "^2.1.0",
"react-native-render-html": "^6.0.0-alpha.10",
"react-native-safe-area-context": "^3.1.4",
Expand All @@ -97,7 +100,7 @@
"rn-fetch-blob": "^0.12.0",
"save": "^2.4.0",
"underscore": "^1.10.2",
"urbanairship-react-native": "^11.0.1"
"urbanairship-react-native": "^11.0.2"
},
"devDependencies": {
"@actions/core": "^1.2.6",
Expand Down
6 changes: 6 additions & 0 deletions src/CONST.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 1 addition & 30 deletions src/Expensify.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {PureComponent} from 'react';
import {View, AppState} from 'react-native';
import Onyx, {withOnyx} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';

import BootSplash from './libs/BootSplash';
import listenToStorageEvents from './libs/listenToStorageEvents';
import * as ActiveClientManager from './libs/ActiveClientManager';
import ONYXKEYS from './ONYXKEYS';
import CONST from './CONST';
import NavigationRoot from './libs/Navigation/NavigationRoot';
import Log from './libs/Log';
import migrateOnyx from './libs/migrateOnyx';
import styles from './styles/styles';
import PushNotification from './libs/Notification/PushNotification';
Expand All @@ -21,32 +18,6 @@ import {growlRef} from './libs/Growl';
import Navigation from './libs/Navigation/Navigation';
import ROUTES from './ROUTES';

// Initialize the store when the app loads for the first time
Onyx.init({
keys: ONYXKEYS,
safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS],
initialKeyStates: {

// Clear any loading and error messages so they do not appear on app startup
[ONYXKEYS.SESSION]: {loading: false, shouldShowComposeInput: true},
[ONYXKEYS.ACCOUNT]: CONST.DEFAULT_ACCOUNT_DATA,
[ONYXKEYS.NETWORK]: {isOffline: false},
[ONYXKEYS.IOU]: {
loading: false, error: false, creatingIOUTransaction: false, isRetrievingCurrency: false,
},
},
registerStorageEventListener: (onStorageEvent) => {
listenToStorageEvents(onStorageEvent);
},
});
Onyx.registerLogger(({level, message}) => {
if (level === 'alert') {
Log.alert(message, 0, {}, false);
} else {
Log.client(message);
}
});

const propTypes = {
/* Onyx Props */

Expand Down
Loading