Skip to content

Commit

Permalink
Add push notification ui/ux and logic
Browse files Browse the repository at this point in the history
Signed-off-by: Jamie Hale <[email protected]>
  • Loading branch information
Jamie Hale authored and jamshale committed Sep 7, 2023
1 parent 9eb1ad0 commit 8fcbd2a
Show file tree
Hide file tree
Showing 28 changed files with 523 additions and 143 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ jobs:
echo "MEDIATOR_URL=${MEDIATOR_URL}" >.env
echo "IAS_PORTAL_URL=${IAS_PORTAL_URL}" >>.env
echo "IAS_AGENT_INVITE_URL=${IAS_AGENT_INVITE_URL}" >>.env
- name: Set Push Notification Capability
working-directory: app/ios/AriesBifold
env:
MEDIATOR_USE_PUSH_NOTIFICATIONS: false
MEDIATOR_LABEL: Mediator
run: |
mv DEVELOPMENT.AriesBifold.entitlements AriesBifold.entitlements
- name: Archive build
working-directory: app/ios
Expand Down
6 changes: 5 additions & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ yarn install

## Configuration

In the `./app/` directory add an `.env` file containing:
In the `./app/` directory copy the .env.sample `cp .env.sample .env`

```
MEDIATOR_URL=<url>
MEDIATOR_USE_PUSH_NOTIFICATIONS=false
MEDIATOR_LABEL=Mediator
```
Push notifications can be used locally on android if the mediator service has the firebase plugin and it's configured correctly.

### Adding ledger configurations

Expand Down
5 changes: 5 additions & 0 deletions app/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MEDIATOR_URL=https://f326-207-194-65-204.ngrok.io?c_i=eyJAdHlwZSI6ICJodHRwczovL2RpZGNvbW0ub3JnL2Nvbm5lY3Rpb25zLzEuMC9pbnZpdGF0aW9uIiwgIkBpZCI6ICI2MjQ0ZThiNS0wNWYzLTRhYWItYjM1Yy1lYWVlMWNmZTAyM2MiLCAicmVjaXBpZW50S2V5cyI6IFsiQ3lqM1BHRUJzQ3RyUGFtTTQyRngza3BlYmR2QWdNd1lGejlFS3RmNnlUN3giXSwgImxhYmVsIjogIk1lZGlhdG9yIiwgInNlcnZpY2VFbmRwb2ludCI6ICJodHRwczovL2YzMjYtMjA3LTE5NC02NS0yMDQubmdyb2suaW8ifQ==

# Push notification variables
MEDIATOR_USE_PUSH_NOTIFICATIONS=false
MEDIATOR_LABEL=Mediator
2 changes: 2 additions & 0 deletions app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import SplashScreen from 'react-native-splash-screen'
import Toast from 'react-native-toast-message'

import bcwallet from './src'
import PushNotifications from './src/components/PushNotifications'
import { credentialOfferTourSteps } from './src/components/tours/CredentialOfferTourSteps'
import { credentialsTourSteps } from './src/components/tours/CredentialsTourSteps'
import { homeTourSteps } from './src/components/tours/HomeTourSteps'
Expand Down Expand Up @@ -139,6 +140,7 @@ const App = () => {
<RootStack />
</TourProvider>
<Toast topOffset={15} config={toastConfig} />
<PushNotifications />
</NetworkProvider>
</AuthProvider>
</ConfigurationProvider>
Expand Down
5 changes: 5 additions & 0 deletions app/__mocks__/@aries-framework/react-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const useAgent = () => ({
agent: {
credentials: mockCredentialModule,
proofs: mockProofModule,
config: {
logger: {
info: jest.fn(),
},
},
},
})
const useCredentialById = jest.fn()
Expand Down
7 changes: 7 additions & 0 deletions app/__mocks__/@react-native-firebase/messaging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const messaging = jest.fn().mockReturnValue({
setBackgroundMessageHandler: jest.fn(),
onMessage: jest.fn(),
requestPermission: jest.fn(),
})

export default messaging
14 changes: 14 additions & 0 deletions app/__mocks__/react-native-permissions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const check = jest.fn()
const request = jest.fn().mockResolvedValue('not-granted')

const PERMISSIONS = {
ANDROID: {
POST_NOTIFICATIONS: 'POST_NOTIFICATIONS',
},
}

const RESULTS = {
GRANTED: 'granted',
}

export { check, request, PERMISSIONS, RESULTS }
69 changes: 38 additions & 31 deletions app/android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
{
"project_info": {
"project_number": "287275049656",
"project_id": "ca-bc-gov-bcwallet",
"storage_bucket": "ca-bc-gov-bcwallet.appspot.com"
"project_number": "493003137594",
"project_id": "ca-bc-gov-bcwallet-2d4df",
"storage_bucket": "ca-bc-gov-bcwallet-2d4df.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:287275049656:android:d707f471af1d6b31b2ca4d",
"android_client_info": {
"package_name": "ca.bc.gov.BCWallet"
{
"client_info": {
"mobilesdk_app_id": "1:493003137594:android:eecbd78be4bc043c890b03",
"android_client_info": {
"package_name": "ca.bc.gov.BCWallet"
}
},
"oauth_client": [
{
"client_id": "493003137594-rgc6pc7cg0nmamc16c5kqs8dpf2gv117.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDIeHtE0Ds_P8LduRhUqDsQqroi-0Ruric"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "493003137594-rgc6pc7cg0nmamc16c5kqs8dpf2gv117.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "493003137594-0cimp1ta4jlq83j63chv1gvi0vgk8sm6.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "ca.bc.gov.BCWallet"
}
},
"oauth_client": [
{
"client_id": "287275049656-g8s9ccd0erc2eqe0o05qbtsb95q7r399.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBpQYLmPFL-3aq8h97us9qCo1bnMeI9npU"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "287275049656-g8s9ccd0erc2eqe0o05qbtsb95q7r399.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
]
}
}
}
],
"configuration_version": "1"
}
}
8 changes: 8 additions & 0 deletions app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
<application android:name=".MainApplication" android:label="@string/app_name"
android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:theme="@style/AppTheme"
android:usesCleartextTraffic="false">
<!-- Push notifications styles -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/logo" />
<meta-data
tools:replace="android:resource"
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/primary" />
<activity android:name=".MainActivity" android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask" android:windowSoftInputMode="adjustResize"
Expand Down
Binary file added app/android/app/src/main/res/drawable/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary">#003468</color>
</resources>
10 changes: 4 additions & 6 deletions app/ios/AriesBifold.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 444;
DEVELOPMENT_TEAM = Q66RAVQTLA;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = AriesBifold/Info.plist;
Expand All @@ -556,7 +555,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = ca.bc.gov.BCWallet.test;
PRODUCT_BUNDLE_IDENTIFIER = ca.bc.gov.BCWallet;
PRODUCT_NAME = BCWallet;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
Expand All @@ -575,7 +574,6 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = Q66RAVQTLA;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = AriesBifold/Info.plist;
Expand All @@ -593,7 +591,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = ca.bc.gov.BCWallet.test;
PRODUCT_BUNDLE_IDENTIFIER = ca.bc.gov.BCWallet;
PRODUCT_NAME = BCWallet;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
Expand Down Expand Up @@ -637,7 +635,7 @@
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 i386";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -701,7 +699,7 @@
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 i386";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down
8 changes: 8 additions & 0 deletions app/ios/AriesBifold/DEVELOPMENT.AriesBifold.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>
4 changes: 4 additions & 0 deletions app/ios/AriesBifold/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
<string>BCSans-Italic.ttf</string>
<string>BCSans-Regular.ttf</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
14 changes: 7 additions & 7 deletions app/ios/GoogleService-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>287275049656-q9jnm4lulpalk9vcl2ubhstg9qoj63c9.apps.googleusercontent.com</string>
<string>493003137594-0cimp1ta4jlq83j63chv1gvi0vgk8sm6.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.287275049656-q9jnm4lulpalk9vcl2ubhstg9qoj63c9</string>
<string>com.googleusercontent.apps.493003137594-0cimp1ta4jlq83j63chv1gvi0vgk8sm6</string>
<key>API_KEY</key>
<string>AIzaSyD9hZM3i0Y8XH7sHl3X1CoIWbevioFyZag</string>
<string>AIzaSyByvJDrhcSJTy27Qqu9_1SPlt_u7r1bi6o</string>
<key>GCM_SENDER_ID</key>
<string>287275049656</string>
<string>493003137594</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>ca.bc.gov.BCWallet</string>
<key>PROJECT_ID</key>
<string>ca-bc-gov-bcwallet</string>
<string>ca-bc-gov-bcwallet-2d4df</string>
<key>STORAGE_BUCKET</key>
<string>ca-bc-gov-bcwallet.appspot.com</string>
<string>ca-bc-gov-bcwallet-2d4df.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
Expand All @@ -29,6 +29,6 @@
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:287275049656:ios:d6bf6e372edd5883b2ca4d</string>
<string>1:493003137594:ios:3ea44407af9632cd890b03</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions app/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ target 'AriesBifold' do
permissions_path = '../node_modules/react-native-permissions/ios'

pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"

use_react_native!(
:path => config[:reactNativePath],
Expand Down
8 changes: 7 additions & 1 deletion app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ PODS:
- nanopb/encode (2.30908.0)
- Permission-Camera (3.8.0):
- RNPermissions
- Permission-Notifications (3.8.0):
- RNPermissions
- PromisesObjC (2.3.1)
- RCT-Folly (2021.06.28.00-v2):
- boost
Expand Down Expand Up @@ -534,6 +536,7 @@ DEPENDENCIES:
- "indy-vdr (from `../node_modules/@hyperledger/indy-vdr-react-native`)"
- libevent (~> 2.1.12)
- Permission-Camera (from `../node_modules/react-native-permissions/ios/Camera`)
- Permission-Notifications (from `../node_modules/react-native-permissions/ios/Notifications`)
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
- RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
Expand Down Expand Up @@ -627,6 +630,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@hyperledger/indy-vdr-react-native"
Permission-Camera:
:path: "../node_modules/react-native-permissions/ios/Camera"
Permission-Notifications:
:path: "../node_modules/react-native-permissions/ios/Notifications"
RCT-Folly:
:podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec"
RCTRequired:
Expand Down Expand Up @@ -756,6 +761,7 @@ SPEC CHECKSUMS:
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96
Permission-Camera: e6d142d7d8b714afe0a83e5e6ae17eb949f1e3e9
Permission-Notifications: aa91ec29236626ff59cb60e08389c0a59a9d32c5
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
RCT-Folly: a21c126816d8025b547704b777a2ba552f3d9fa9
RCTRequired: 405e24508a0feed1771d48caebb85c581db53122
Expand Down Expand Up @@ -809,6 +815,6 @@ SPEC CHECKSUMS:
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4
Yoga: b316a990bb6d115afa1b436b5626ac7c61717d17

PODFILE CHECKSUM: 82610b73457852133d43633aae82952a9980fb31
PODFILE CHECKSUM: d8c135e878f21c2bf8dfc27d38fd85e819cbe188

COCOAPODS: 1.12.1
4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"homepage": "https://github.com/bcgov/bc-wallet-mobile#readme",
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios --device",
"ios": "react-native run-ios",
"start": "react-native start --reset-cache",
"style-check": "yarn prettier -- --check",
"style-format": "yarn prettier -- --write",
Expand Down Expand Up @@ -96,7 +96,7 @@
"react-native-inappbrowser-reborn": "^3.7.0",
"react-native-keychain": "^7.0.0",
"react-native-localize": "^2.2.4",
"react-native-permissions": "^3.6.1",
"react-native-permissions": "3.6.1",
"react-native-qrcode-svg": "6.1.1",
"react-native-reanimated": "2.2.4",
"react-native-safe-area-context": "3.3.2",
Expand Down
Binary file added app/src/assets/img/push-notifications.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8fcbd2a

Please sign in to comment.