Skip to content

Commit 31afc54

Browse files
committed
feat(ionic-portals): allow initial context handling
1 parent 62068e5 commit 31afc54

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

packages/ionic-portals/index.android.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ export class IonicPortalManager {
66
io.ionic.portals.PortalManager.register(apiKey);
77
}
88

9-
static create(portalId: string, startDir?: string, plugins?: Array<string>) {
9+
static create(portalId: string, startDir?: string, plugins?: Array<string>, initialContext?: any) {
1010
const builder = io.ionic.portals.PortalManager.newPortal(portalId).setStartDir(startDir || portalId);
11+
if (initialContext) {
12+
const javaMap = new java.util.Map();
13+
for (const key in initialContext) {
14+
javaMap.put(key, initialContext[key]);
15+
}
16+
builder.setInitialContext(javaMap);
17+
}
1118
let list: java.util.ArrayList<any>;
1219
if (typeof com !== 'undefined' && com?.capacitorjs?.plugins) {
1320
// auto register all official plugins detected

packages/ionic-portals/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export declare class IonicPortalManager {
1616
* iOS: App_Resources/iOS/webPortal
1717
* Android: App_Resources/Android/src/main/asssets/webPortal
1818
*/
19-
static create(portalId: string, startDir?: string, plugins?: Array<string> /* Android only - if using non-official Capacitor plugins, can pass array of fully qualified plugin namespaces */): any;
19+
static create(portalId: string, startDir?: string, plugins?: Array<string> /* Android only - if using non-official Capacitor plugins, can pass array of fully qualified plugin namespaces */, initialContext?: any): any;
2020
}
2121
export declare class IonicPortal extends IonicPortalCommon {}

packages/ionic-portals/index.ios.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ export class IonicPortalManager {
66
PortalManager.register(apiKey);
77
}
88

9-
static create(portalId: string, startDir?: string) {
10-
return PortalManager.newPortal(portalId)
11-
.setStartDir(startDir || portalId)
12-
.create();
9+
static create(portalId: string, startDir?: string, plugins?: Array<string>, initialContext?: any) {
10+
const builder = PortalManager.newPortal(portalId).setStartDir(startDir || portalId);
11+
if (initialContext) {
12+
builder.setInitialContext(initialContext);
13+
}
14+
return builder.create();
1315
}
1416
}
1517

0 commit comments

Comments
 (0)