Skip to content

Commit

Permalink
Clean up some development code and logic
Browse files Browse the repository at this point in the history
Signed-off-by: Jamie Hale <jamiehalebc@gmail.com>
  • Loading branch information
jamshale committed Aug 18, 2023
1 parent 7750248 commit eb039ac
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
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
6 changes: 2 additions & 4 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
2 changes: 1 addition & 1 deletion 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
8 changes: 6 additions & 2 deletions app/src/helpers/PushNotificationsHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Agent } from '@aries-framework/core'
import AsyncStorage from '@react-native-async-storage/async-storage'
import messaging from '@react-native-firebase/messaging'
import { Platform } from 'react-native'
import { Config } from 'react-native-config'

interface SetDeviceInfoOptions {
Expand All @@ -10,12 +11,15 @@ interface SetDeviceInfoOptions {
// Will send the device token to the mediator agent if it is undefined or has changed, otherwise it will do nothing
export async function setDeviceInfo({ agent }: SetDeviceInfoOptions) {
if (!Config.MEDIATOR_USE_PUSH_NOTIFICATIONS) return
if (!agent) return

// Need to register for push notification capability on iOS
if (Platform.OS === 'ios' && !messaging().isDeviceRegisteredForRemoteMessages)
await messaging().registerDeviceForRemoteMessages()

const token = await messaging().getToken()
if ((await AsyncStorage.getItem('deviceToken')) === token) return

if (!agent) return

agent.config.logger.info('Change of push notification token detected, sending to agent')
const connections = await agent.connections.findAllByQuery({})
connections.forEach(async (c) => {
Expand Down

0 comments on commit eb039ac

Please sign in to comment.