diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6d9cf2cb8..10c7425e3 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -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 diff --git a/DEVELOPER.md b/DEVELOPER.md index 8c1f44898..8b4e49cff 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -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= + +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 diff --git a/app/.env.sample b/app/.env.sample new file mode 100644 index 000000000..e41dbc7fe --- /dev/null +++ b/app/.env.sample @@ -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 \ No newline at end of file diff --git a/app/App.tsx b/app/App.tsx index 1ebb6d517..a883956ba 100644 --- a/app/App.tsx +++ b/app/App.tsx @@ -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' @@ -139,6 +140,7 @@ const App = () => { + diff --git a/app/__mocks__/@aries-framework/react-hooks.ts b/app/__mocks__/@aries-framework/react-hooks.ts index c849c39b9..9dd991f54 100644 --- a/app/__mocks__/@aries-framework/react-hooks.ts +++ b/app/__mocks__/@aries-framework/react-hooks.ts @@ -23,6 +23,11 @@ const useAgent = () => ({ agent: { credentials: mockCredentialModule, proofs: mockProofModule, + config: { + logger: { + info: jest.fn(), + }, + }, }, }) const useCredentialById = jest.fn() diff --git a/app/__mocks__/@react-native-firebase/messaging.ts b/app/__mocks__/@react-native-firebase/messaging.ts new file mode 100644 index 000000000..c1d7cc6d7 --- /dev/null +++ b/app/__mocks__/@react-native-firebase/messaging.ts @@ -0,0 +1,7 @@ +const messaging = jest.fn().mockReturnValue({ + setBackgroundMessageHandler: jest.fn(), + onMessage: jest.fn(), + requestPermission: jest.fn(), +}) + +export default messaging diff --git a/app/__mocks__/react-native-permissions.ts b/app/__mocks__/react-native-permissions.ts new file mode 100644 index 000000000..7323dd6fb --- /dev/null +++ b/app/__mocks__/react-native-permissions.ts @@ -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 } diff --git a/app/android/app/google-services.json b/app/android/app/google-services.json index dc9a4383e..6ed9a3cca 100644 --- a/app/android/app/google-services.json +++ b/app/android/app/google-services.json @@ -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" -} \ No newline at end of file + } \ No newline at end of file diff --git a/app/android/app/src/main/AndroidManifest.xml b/app/android/app/src/main/AndroidManifest.xml index d34652e0e..55500690c 100644 --- a/app/android/app/src/main/AndroidManifest.xml +++ b/app/android/app/src/main/AndroidManifest.xml @@ -18,6 +18,14 @@ + + + + + #003468 + \ No newline at end of file diff --git a/app/ios/AriesBifold.xcodeproj/project.pbxproj b/app/ios/AriesBifold.xcodeproj/project.pbxproj index 925cb81d0..c3b0bb323 100644 --- a/app/ios/AriesBifold.xcodeproj/project.pbxproj +++ b/app/ios/AriesBifold.xcodeproj/project.pbxproj @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/app/ios/AriesBifold/DEVELOPMENT.AriesBifold.entitlements b/app/ios/AriesBifold/DEVELOPMENT.AriesBifold.entitlements new file mode 100644 index 000000000..308ab6fa5 --- /dev/null +++ b/app/ios/AriesBifold/DEVELOPMENT.AriesBifold.entitlements @@ -0,0 +1,8 @@ + + + + + aps-environment + development + + \ No newline at end of file diff --git a/app/ios/AriesBifold/Info.plist b/app/ios/AriesBifold/Info.plist index 012c94168..15daf70c1 100644 --- a/app/ios/AriesBifold/Info.plist +++ b/app/ios/AriesBifold/Info.plist @@ -69,6 +69,10 @@ BCSans-Italic.ttf BCSans-Regular.ttf + UIBackgroundModes + + remote-notification + UILaunchStoryboardName LaunchScreen UIRequiredDeviceCapabilities diff --git a/app/ios/GoogleService-Info.plist b/app/ios/GoogleService-Info.plist index 9f092b63b..f085053ba 100644 --- a/app/ios/GoogleService-Info.plist +++ b/app/ios/GoogleService-Info.plist @@ -3,21 +3,21 @@ CLIENT_ID - 287275049656-q9jnm4lulpalk9vcl2ubhstg9qoj63c9.apps.googleusercontent.com + 493003137594-0cimp1ta4jlq83j63chv1gvi0vgk8sm6.apps.googleusercontent.com REVERSED_CLIENT_ID - com.googleusercontent.apps.287275049656-q9jnm4lulpalk9vcl2ubhstg9qoj63c9 + com.googleusercontent.apps.493003137594-0cimp1ta4jlq83j63chv1gvi0vgk8sm6 API_KEY - AIzaSyD9hZM3i0Y8XH7sHl3X1CoIWbevioFyZag + AIzaSyByvJDrhcSJTy27Qqu9_1SPlt_u7r1bi6o GCM_SENDER_ID - 287275049656 + 493003137594 PLIST_VERSION 1 BUNDLE_ID ca.bc.gov.BCWallet PROJECT_ID - ca-bc-gov-bcwallet + ca-bc-gov-bcwallet-2d4df STORAGE_BUCKET - ca-bc-gov-bcwallet.appspot.com + ca-bc-gov-bcwallet-2d4df.appspot.com IS_ADS_ENABLED IS_ANALYTICS_ENABLED @@ -29,6 +29,6 @@ IS_SIGNIN_ENABLED GOOGLE_APP_ID - 1:287275049656:ios:d6bf6e372edd5883b2ca4d + 1:493003137594:ios:3ea44407af9632cd890b03 \ No newline at end of file diff --git a/app/ios/Podfile b/app/ios/Podfile index f64d85b24..c36ece8a4 100644 --- a/app/ios/Podfile +++ b/app/ios/Podfile @@ -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], diff --git a/app/ios/Podfile.lock b/app/ios/Podfile.lock index 60d068e53..f4900a242 100644 --- a/app/ios/Podfile.lock +++ b/app/ios/Podfile.lock @@ -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 @@ -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`) @@ -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: @@ -756,6 +761,7 @@ SPEC CHECKSUMS: libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96 Permission-Camera: e6d142d7d8b714afe0a83e5e6ae17eb949f1e3e9 + Permission-Notifications: aa91ec29236626ff59cb60e08389c0a59a9d32c5 PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 RCT-Folly: a21c126816d8025b547704b777a2ba552f3d9fa9 RCTRequired: 405e24508a0feed1771d48caebb85c581db53122 @@ -809,6 +815,6 @@ SPEC CHECKSUMS: RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4 Yoga: b316a990bb6d115afa1b436b5626ac7c61717d17 -PODFILE CHECKSUM: 82610b73457852133d43633aae82952a9980fb31 +PODFILE CHECKSUM: d8c135e878f21c2bf8dfc27d38fd85e819cbe188 COCOAPODS: 1.12.1 diff --git a/app/package.json b/app/package.json index 6b8becaaf..d71018d8a 100644 --- a/app/package.json +++ b/app/package.json @@ -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", @@ -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", diff --git a/app/src/assets/img/push-notifications.png b/app/src/assets/img/push-notifications.png new file mode 100644 index 000000000..3087b5396 Binary files /dev/null and b/app/src/assets/img/push-notifications.png differ diff --git a/app/src/components/HomeFooterView.tsx b/app/src/components/HomeFooterView.tsx index 87fb2e9b2..651345c57 100644 --- a/app/src/components/HomeFooterView.tsx +++ b/app/src/components/HomeFooterView.tsx @@ -1,4 +1,3 @@ -import { useAgent } from '@aries-framework/react-hooks' import { Button, ButtonType, testIdWithKey, useTheme } from 'aries-bifold' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' @@ -6,11 +5,8 @@ import { StyleSheet, View } from 'react-native' import Icon from 'react-native-vector-icons/MaterialCommunityIcons' import { surveyMonkeyUrl, surveyMonkeyExitUrl } from '../constants' -import { setDeviceInfo } from '../helpers/PushNotificationsHelper' import WebDisplay from '../screens/WebDisplay' -import PushNotifications from './PushNotifications' - interface HomeFooterViewProps { children?: any } @@ -19,7 +15,6 @@ const HomeFooterView: React.FC = ({ children }) => { const { ColorPallet } = useTheme() const { t } = useTranslation() const [surveyVisible, setSurveyVisible] = useState(false) - const { agent } = useAgent() const styles = StyleSheet.create({ feedbackContainer: { @@ -35,9 +30,6 @@ const HomeFooterView: React.FC = ({ children }) => { const toggleSurveyVisibility = () => setSurveyVisible(!surveyVisible) - // Attempt to set device info for push notifications - setDeviceInfo({ agent }) - return (