Skip to content

Commit

Permalink
feat: push notifications (#1389)
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale authored Sep 26, 2023
1 parent 6d113fe commit 64d72f7
Show file tree
Hide file tree
Showing 30 changed files with 1,542 additions and 55 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ jobs:
echo "IAS_PORTAL_URL=${IAS_PORTAL_URL}" >>.env
echo "IAS_AGENT_INVITE_URL=${IAS_AGENT_INVITE_URL}" >>.env
echo "OCA_URL=${OCA_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 }
4 changes: 4 additions & 0 deletions app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ dependencies {

implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

implementation platform('com.google.firebase:firebase-bom:26.4.0')

if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
Expand All @@ -239,3 +241,5 @@ task copyDownloadableDepsToLibs(type: Copy) {

apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

apply plugin: 'com.google.gms.google-services'
46 changes: 46 additions & 0 deletions app/android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"project_info": {
"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: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"
}
}
]
}
}
}
],
"configuration_version": "1"
}
59 changes: 30 additions & 29 deletions app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ca.bc.gov.BCWallet">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ca.bc.gov.BCWallet"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.USE_BIOMETRICS" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission-sdk-23 android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission-sdk-23 android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https"/>
<data android:scheme="https" />
</intent>
</queries>

<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:resizeableActivity="false"
android:theme="@style/AppTheme"

<application android:name=".MainApplication" android:label="@string/app_name"
android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:theme="@style/AppTheme"
android:usesCleartextTraffic="false">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait"
android:exported="true">
<!-- 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"
android:screenOrientation="portrait" android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="didcomm"/>
<data android:scheme="bcwallet"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="didcomm" />
<data android:scheme="bcwallet" />
</intent-filter>
</activity>
</application>
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>
1 change: 1 addition & 0 deletions app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ buildscript {
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath 'com.google.gms:google-services:4.3.15'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
Loading

0 comments on commit 64d72f7

Please sign in to comment.