diff --git a/packages/app-runtime/src/AppConfig.ts b/packages/app-runtime/src/AppConfig.ts index acf4791cd..e1db0e2b1 100644 --- a/packages/app-runtime/src/AppConfig.ts +++ b/packages/app-runtime/src/AppConfig.ts @@ -5,6 +5,7 @@ import { defaultsDeep } from "lodash"; export interface AppConfig extends RuntimeConfig { accountsDbName: string; applicationId: string; + pushService: "apns" | "fcm" | "none" | "dummy"; applePushEnvironment?: "Development" | "Production"; allowMultipleAccountsWithSameAddress: boolean; databaseFolder: string; @@ -14,6 +15,7 @@ export interface AppConfigOverwrite { transportLibrary?: Omit; accountsDbName?: string; applicationId?: string; + pushService?: "apns" | "fcm" | "none" | "dummy"; applePushEnvironment?: "Development" | "Production"; allowMultipleAccountsWithSameAddress?: boolean; databaseFolder?: string; @@ -25,6 +27,9 @@ export function createAppConfig(...configs: (AppConfigOverwrite | AppConfig)[]): transportLibrary: Omit; } = { accountsDbName: "accounts", + pushService: "none", + allowMultipleAccountsWithSameAddress: false, + databaseFolder: "./data", transportLibrary: { datawalletEnabled: true }, @@ -107,9 +112,7 @@ export function createAppConfig(...configs: (AppConfigOverwrite | AppConfig)[]): displayName: "Notification Module", location: "@nmshd/runtime:NotificationModule" } - }, - allowMultipleAccountsWithSameAddress: false, - databaseFolder: "./data" + } }; const mergedConfig = defaultsDeep({}, ...configs, appConfig); diff --git a/packages/app-runtime/src/modules/AppRuntimeModule.ts b/packages/app-runtime/src/modules/AppRuntimeModule.ts index a1a65e2ee..1853ae7e5 100644 --- a/packages/app-runtime/src/modules/AppRuntimeModule.ts +++ b/packages/app-runtime/src/modules/AppRuntimeModule.ts @@ -1,5 +1,4 @@ import { ILogger } from "@js-soft/logging-abstractions"; -import { EventHandler, SubscriptionTarget } from "@js-soft/ts-utils"; import { ModuleConfiguration, RuntimeModule } from "@nmshd/runtime"; import { AppRuntime } from "../AppRuntime"; @@ -11,16 +10,4 @@ export interface AppRuntimeModuleConfiguration extends ModuleConfiguration {} export abstract class AppRuntimeModule extends RuntimeModule { private readonly nativeEventSubscriptionIds: number[] = []; - - protected subscribeToNativeEvent(event: SubscriptionTarget, handler: EventHandler): void { - const subscriptionResult = this.runtime.nativeEnvironment.eventBus.subscribe(event, handler); - this.nativeEventSubscriptionIds.push(subscriptionResult); - } - - protected override unsubscribeFromAllEvents(): void { - super.unsubscribeFromAllEvents(); - - this.nativeEventSubscriptionIds.forEach((id) => this.runtime.nativeEnvironment.eventBus.unsubscribe(id)); - this.nativeEventSubscriptionIds.splice(0); - } } diff --git a/packages/app-runtime/src/modules/PushNotificationModule.ts b/packages/app-runtime/src/modules/PushNotificationModule.ts index b4a2b0747..13848765b 100644 --- a/packages/app-runtime/src/modules/PushNotificationModule.ts +++ b/packages/app-runtime/src/modules/PushNotificationModule.ts @@ -24,8 +24,8 @@ export class PushNotificationModule extends AppRuntimeModule { } public start(): void { - this.subscribeToNativeEvent(UrlOpenEvent, this.handleUrlOpen.bind(this)); + this.subscribeToEvent(UrlOpenEvent, this.handleUrlOpen.bind(this)); } private async handleUrlOpen(event: UrlOpenEvent) { diff --git a/packages/app-runtime/src/natives/INativeDeviceInfoAccess.ts b/packages/app-runtime/src/natives/INativeDeviceInfoAccess.ts deleted file mode 100644 index 5e6708145..000000000 --- a/packages/app-runtime/src/natives/INativeDeviceInfoAccess.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Result } from "@js-soft/ts-utils"; - -export interface INativeDeviceInfoAccess { - init(): Promise>; - deviceInfo: INativeDeviceInfo; -} - -export interface INativeDeviceInfo { - model: string; - platform: string; - uuid: string; - version: string; - manufacturer: string; - isVirtual: boolean; - languageCode: string; - pushService: "apns" | "fcm" | "none" | "dummy"; -} diff --git a/packages/app-runtime/src/natives/INativeEnvironment.ts b/packages/app-runtime/src/natives/INativeEnvironment.ts index 66513d55c..edc6b8223 100644 --- a/packages/app-runtime/src/natives/INativeEnvironment.ts +++ b/packages/app-runtime/src/natives/INativeEnvironment.ts @@ -1,8 +1,6 @@ import { ILokiJsDatabaseFactory } from "@js-soft/docdb-access-loki"; import { ILoggerFactory } from "@js-soft/logging-abstractions"; -import { EventBus } from "@js-soft/ts-utils"; import { INativeConfigAccess } from "./INativeConfigAccess"; -import { INativeDeviceInfoAccess } from "./INativeDeviceInfoAccess"; import { INativeNotificationAccess } from "./INativeNotificationAccess"; export interface INativeEnvironment { @@ -10,6 +8,4 @@ export interface INativeEnvironment { configAccess: INativeConfigAccess; loggerFactory: ILoggerFactory; notificationAccess: INativeNotificationAccess; - eventBus: EventBus; - deviceInfoAccess: INativeDeviceInfoAccess; } diff --git a/packages/app-runtime/src/natives/index.ts b/packages/app-runtime/src/natives/index.ts index 0d58e1851..a041d03fd 100644 --- a/packages/app-runtime/src/natives/index.ts +++ b/packages/app-runtime/src/natives/index.ts @@ -1,7 +1,6 @@ export * from "./events"; export * from "./INativeBootstrapper"; export * from "./INativeConfigAccess"; -export * from "./INativeDeviceInfoAccess"; export * from "./INativeEnvironment"; export * from "./INativeNotificationAccess"; export * from "./INativeTranslationProvider"; diff --git a/packages/app-runtime/test/lib/TestUtil.ts b/packages/app-runtime/test/lib/TestUtil.ts index eb33b4a55..2bc57acca 100644 --- a/packages/app-runtime/test/lib/TestUtil.ts +++ b/packages/app-runtime/test/lib/TestUtil.ts @@ -34,7 +34,7 @@ export class TestUtil { const config = this.createAppConfig(configOverride); - const nativeBootstrapper = new FakeNativeBootstrapper(eventBus); + const nativeBootstrapper = new FakeNativeBootstrapper(); await nativeBootstrapper.init(); const runtime = await AppRuntime.create(nativeBootstrapper, config, eventBus); runtime.registerUIBridge(uiBridge); diff --git a/packages/app-runtime/test/lib/natives/FakeNativeBootstrapper.ts b/packages/app-runtime/test/lib/natives/FakeNativeBootstrapper.ts index 366207901..75d509967 100644 --- a/packages/app-runtime/test/lib/natives/FakeNativeBootstrapper.ts +++ b/packages/app-runtime/test/lib/natives/FakeNativeBootstrapper.ts @@ -1,14 +1,11 @@ import { NodeLoggerFactory } from "@js-soft/node-logger"; -import { EventBus, EventEmitter2EventBus, Result } from "@js-soft/ts-utils"; +import { Result } from "@js-soft/ts-utils"; import { INativeBootstrapper, INativeEnvironment } from "../../../src"; import { FakeNativeConfigAccess } from "./FakeNativeConfigAccess"; import { FakeNativeDatabaseFactory } from "./FakeNativeDatabaseFactory"; -import { FakeNativeDeviceInfoAccess } from "./FakeNativeDeviceInfoAccess"; import { FakeNativeNotificationAccess } from "./FakeNativeNotificationAccess"; export class FakeNativeBootstrapper implements INativeBootstrapper { - public constructor(private readonly eventBus?: EventBus) {} - private _nativeEnvironment: INativeEnvironment; public get nativeEnvironment(): INativeEnvironment { return this._nativeEnvironment; @@ -45,17 +42,10 @@ export class FakeNativeBootstrapper implements INativeBootstrapper { this._nativeEnvironment = { configAccess: new FakeNativeConfigAccess(), databaseFactory: new FakeNativeDatabaseFactory(), - deviceInfoAccess: new FakeNativeDeviceInfoAccess(), - eventBus: - this.eventBus ?? - new EventEmitter2EventBus(() => { - // noop - }), loggerFactory, notificationAccess: new FakeNativeNotificationAccess(nativeLogger) }; - await this._nativeEnvironment.deviceInfoAccess.init(); await this._nativeEnvironment.notificationAccess.init(); return Result.ok(undefined); diff --git a/packages/app-runtime/test/lib/natives/FakeNativeDeviceInfoAccess.ts b/packages/app-runtime/test/lib/natives/FakeNativeDeviceInfoAccess.ts deleted file mode 100644 index ca19854d6..000000000 --- a/packages/app-runtime/test/lib/natives/FakeNativeDeviceInfoAccess.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Result } from "@js-soft/ts-utils"; -import { INativeDeviceInfo, INativeDeviceInfoAccess } from "../../../src"; - -export class FakeNativeDeviceInfoAccess implements INativeDeviceInfoAccess { - public get deviceInfo(): INativeDeviceInfo { - return { - uuid: "00000000-7e7a-4e82-bd56-9cdba102ac13", - model: "Model", - isVirtual: true, - languageCode: "de", - manufacturer: "Manufacturer", - platform: "Platform", - version: "Version", - pushService: "dummy" - }; - } - - public init(): Promise> { - return Promise.resolve(Result.ok(this.deviceInfo)); - } -} diff --git a/packages/app-runtime/test/modules/PushNotification.test.ts b/packages/app-runtime/test/modules/PushNotification.test.ts index c6c9bacdc..95188e4a6 100644 --- a/packages/app-runtime/test/modules/PushNotification.test.ts +++ b/packages/app-runtime/test/modules/PushNotification.test.ts @@ -10,7 +10,7 @@ describe("PushNotificationModuleTest", function () { let devicePushIdentifier = "dummy value"; beforeAll(async function () { - runtime = await TestUtil.createRuntime({ modules: { pushNotification: { enabled: true } } }, undefined, eventBus); + runtime = await TestUtil.createRuntime({ pushService: "dummy", modules: { pushNotification: { enabled: true } } }, undefined, eventBus); await runtime.start(); const accounts = await TestUtil.provideAccounts(runtime, 1); @@ -24,7 +24,7 @@ describe("PushNotificationModuleTest", function () { afterEach(() => eventBus.reset()); test("should persist push identifier", async function () { - runtime.nativeEnvironment.eventBus.publish(new RemoteNotificationRegistrationEvent("handleLongerThan10Characters")); + runtime.eventBus.publish(new RemoteNotificationRegistrationEvent("handleLongerThan10Characters")); await eventBus.waitForRunningEventHandlers(); @@ -35,7 +35,7 @@ describe("PushNotificationModuleTest", function () { }); test("should do a datawallet sync when DatawalletModificationsCreated is received", async function () { - runtime.nativeEnvironment.eventBus.publish( + runtime.eventBus.publish( new RemoteNotificationEvent({ content: { devicePushIdentifier: devicePushIdentifier, @@ -50,7 +50,7 @@ describe("PushNotificationModuleTest", function () { }); test("should do a sync everything when ExternalEventCreated is received", async function () { - runtime.nativeEnvironment.eventBus.publish( + runtime.eventBus.publish( new RemoteNotificationEvent({ content: { devicePushIdentifier: devicePushIdentifier,