@mpgd/adapter-capacitor 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -194,6 +194,7 @@ import { resolveNotificationTopicsForTarget } from '@mpgd/catalog';
194
194
  import {
195
195
  createCapacitorNotificationServiceProvider,
196
196
  loadCapacitorNotificationSdks,
197
+ openCapacitorNotificationSettings,
197
198
  } from '@mpgd/adapter-capacitor/notifications';
198
199
 
199
200
  const sdks = await loadCapacitorNotificationSdks();
@@ -201,8 +202,8 @@ const notifications = createCapacitorNotificationServiceProvider({
201
202
  platform: 'android',
202
203
  topics: resolveNotificationTopicsForTarget(catalog, 'android'),
203
204
  ...sdks,
204
- // Optional: opens this app's notification settings (see below).
205
- openSettings,
205
+ // Opens this app's notification settings (see below).
206
+ openSettings: openCapacitorNotificationSettings,
206
207
  });
207
208
  const gateway = createCapacitorPlatformGateway({ ..., providers: [notifications] });
208
209
  ```
@@ -296,11 +297,21 @@ is created, which is how a cold-start open reaches it.
296
297
  - The action opens the `optOutRoute` of the advertising topic the push names
297
298
  in its `topic` data key; without that key it opens nothing.
298
299
  - An Android FCM notification message cannot carry actions, so an Android
299
- advertising push needs the shell to render it natively with the action;
300
- the template work for that is C1's.
301
- - **Settings.** Neither plugin opens the notification settings, so the shell
302
- passes `openSettings` (for example a small native method); without it
303
- `permission.settings` is `false` and `openSettings` answers `unavailable`.
300
+ advertising push needs the shell to render it natively with the action,
301
+ which is not built yet (a follow-up after C1). Until then map no
302
+ advertising topic to `android`: the push would arrive without the
303
+ opt-out action the Korean rules require (see the RFC's advertising
304
+ rules). The kit's starter maps its sample advertising topic to iOS only.
305
+ - **Settings.** Neither plugin opens the notification settings, so the
306
+ provider takes an `openSettings` opener; without one `permission.settings`
307
+ is `false` and `openSettings` answers `unavailable`.
308
+ `openCapacitorNotificationSettings` is the kit's opener: it calls
309
+ `openNotificationSettings` of `@mpgd/capacitor-game-services` (Android 8+
310
+ `Settings.ACTION_APP_NOTIFICATION_SETTINGS`, iOS 16+
311
+ `UIApplication.openNotificationSettingsURLString`, and each app's settings
312
+ page on older versions) and throws when the screen did not open. A shell
313
+ built with a plugin older than the method rejects the call, and the
314
+ provider then answers `unavailable` and reports the error.
304
315
  The provider resolves `openSettings` only once the app is back in the
305
316
  foreground, after at most two minutes (`settingsReturnTimeoutMs`), or after
306
317
  five seconds when the app never left.
@@ -0,0 +1,14 @@
1
+ import { type CapacitorGameServicesPlugin } from '@mpgd/capacitor-game-services';
2
+ /** The part of `@mpgd/capacitor-game-services` the settings opener calls. */
3
+ export type CapacitorNotificationSettingsPlugin = Pick<CapacitorGameServicesPlugin, 'openNotificationSettings'>;
4
+ /**
5
+ * Opens this app's notification settings through
6
+ * `@mpgd/capacitor-game-services` (Android 8+ app notification settings, iOS
7
+ * 16+ notification settings, each app's settings page on older versions).
8
+ * Pass it as the provider's `openSettings`, which then declares
9
+ * `permission.settings: true` and waits for the player to come back. It
10
+ * throws when the system could not open the screen, and the plugin rejects
11
+ * it as unimplemented in a shell built with a plugin older than the method;
12
+ * the provider reports either failure and answers `unavailable`.
13
+ */
14
+ export declare function openCapacitorNotificationSettings(plugin?: CapacitorNotificationSettingsPlugin): Promise<void>;
@@ -0,0 +1,18 @@
1
+ import { CapacitorGameServices, } from '@mpgd/capacitor-game-services';
2
+ /**
3
+ * Opens this app's notification settings through
4
+ * `@mpgd/capacitor-game-services` (Android 8+ app notification settings, iOS
5
+ * 16+ notification settings, each app's settings page on older versions).
6
+ * Pass it as the provider's `openSettings`, which then declares
7
+ * `permission.settings: true` and waits for the player to come back. It
8
+ * throws when the system could not open the screen, and the plugin rejects
9
+ * it as unimplemented in a shell built with a plugin older than the method;
10
+ * the provider reports either failure and answers `unavailable`.
11
+ */
12
+ export async function openCapacitorNotificationSettings(plugin = CapacitorGameServices) {
13
+ const result = await plugin.openNotificationSettings();
14
+ if (typeof result !== 'object' || result === null
15
+ || result.opened !== true) {
16
+ throw new Error('The notification settings screen could not be opened.');
17
+ }
18
+ }
@@ -3,6 +3,7 @@ import type { CapacitorNotificationServiceProvider } from './providers.js';
3
3
  export { capacitorNotificationPluginNames, loadCapacitorNotificationSdks, type CapacitorNotificationSdkRuntime, type CapacitorNotificationSdks, type LoadCapacitorNotificationSdksInput, type LocalNotificationSdk, type LocalNotificationSdkActionType, type LocalNotificationSdkEntry, type LocalNotificationSdkSchema, type NotificationSdkChannel, type PushSdk, type PushSdkActionEvent, type PushSdkNotification, } from './notifications-sdk.js';
4
4
  export { capacitorAdvertisingActionTypeId, capacitorIosMaxPendingLocalNotifications, capacitorLocalNotificationId, capacitorNotificationChannelId, capacitorNotificationDataKeys, capacitorNotificationProviderId, capacitorSettingsLeaveTimeoutMs, capacitorSettingsReturnTimeoutMs, createCapacitorNotificationProvider, type CapacitorNotificationAppEvents, type CapacitorNotificationChannelSettings, type CapacitorNotificationProvider, type CreateCapacitorNotificationProviderInput, } from './notifications-provider.js';
5
5
  export { createBridgeNotificationProvider, createNotificationProviderBridge, createNotificationServiceProvider, createNotificationSubscriptionAdapter, type CreateBridgeNotificationProviderInput, type CreateNotificationProviderBridgeInput, type CreateNotificationServiceProviderInput, type NotificationProviderBridge, } from './notifications-bridge.js';
6
+ export { openCapacitorNotificationSettings, type CapacitorNotificationSettingsPlugin, } from './notifications-settings.js';
6
7
  export type { CapacitorNotificationServiceProvider, CapacitorNotificationsV2Service, } from './providers.js';
7
8
  export interface CreateCapacitorNotificationServiceProviderInput extends CreateCapacitorNotificationProviderInput {
8
9
  /** The registry id; 'capacitor-notifications' when absent. */
@@ -8,6 +8,7 @@ import { createCapacitorNotificationProvider, } from './notifications-provider.j
8
8
  export { capacitorNotificationPluginNames, loadCapacitorNotificationSdks, } from './notifications-sdk.js';
9
9
  export { capacitorAdvertisingActionTypeId, capacitorIosMaxPendingLocalNotifications, capacitorLocalNotificationId, capacitorNotificationChannelId, capacitorNotificationDataKeys, capacitorNotificationProviderId, capacitorSettingsLeaveTimeoutMs, capacitorSettingsReturnTimeoutMs, createCapacitorNotificationProvider, } from './notifications-provider.js';
10
10
  export { createBridgeNotificationProvider, createNotificationProviderBridge, createNotificationServiceProvider, createNotificationSubscriptionAdapter, } from './notifications-bridge.js';
11
+ export { openCapacitorNotificationSettings, } from './notifications-settings.js';
11
12
  /**
12
13
  * The provider and its registry entry in one call, with the same topics, for
13
14
  * `createCapacitorPlatformGateway({ providers: [...] })`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpgd/adapter-capacitor",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Capacitor platform adapter for mpgd Android and iOS shells.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,11 +43,11 @@
43
43
  ],
44
44
  "dependencies": {
45
45
  "@capacitor/app": "8.1.1",
46
- "@mpgd/bridge": "0.13.2",
47
- "@mpgd/game-services": "0.25.0",
48
- "@mpgd/capacitor-game-services": "0.7.2",
49
- "@mpgd/platform": "0.24.0",
50
- "@mpgd/target-config": "0.23.2"
46
+ "@mpgd/capacitor-game-services": "0.8.0",
47
+ "@mpgd/bridge": "0.14.1",
48
+ "@mpgd/platform": "0.26.0",
49
+ "@mpgd/game-services": "0.26.0",
50
+ "@mpgd/target-config": "0.23.4"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@capacitor-community/admob": "^8.1.0",
@@ -74,7 +74,7 @@
74
74
  "ttsc": "0.32.1",
75
75
  "typescript": "7.0.2",
76
76
  "vitest": "^4.0.0",
77
- "@mpgd/game-runtime": "0.7.2"
77
+ "@mpgd/game-runtime": "0.7.4"
78
78
  },
79
79
  "main": "./dist/index.js",
80
80
  "types": "./dist/index.d.ts",