@livx.cc/appwrap 0.25.0 → 0.25.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livx.cc/appwrap",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "description": "Wrap any PWA into a native app with native capabilities (appwrap runtime + @livx.cc/native-kit).",
5
5
  "license": "MIT",
6
6
  "author": "Elya Livshitz",
@@ -166,6 +166,18 @@ export function registerPushHandlers(): void {
166
166
  if (isAndroid) return androidDeleteToken();
167
167
  });
168
168
 
169
+ // Dev/demo: ask the backend to push THIS device on demand. Goes native (NS Http) → no app:// CORS
170
+ // wall. Requires push.registrationUrl + a registered token; the backend honors `test:true`.
171
+ bridge.register('push.sendTest', () => {
172
+ const url = SHELL_CONFIG.pushRegistrationUrl;
173
+ if (!url) return Promise.reject(Object.assign(new Error('push.registrationUrl not configured'), { code: 'UNSUPPORTED' }));
174
+ if (!cachedToken) return Promise.reject(Object.assign(new Error('no device token yet — register first'), { code: 'NOT_READY' }));
175
+ return Http.request({
176
+ url, method: 'POST', headers: { 'Content-Type': 'application/json' },
177
+ content: JSON.stringify({ token: cachedToken, platform: isIOS ? 'ios' : 'android', test: true }),
178
+ }).then((res) => ({ status: res.statusCode }));
179
+ });
180
+
169
181
  // Debug: auto-acquire + log the FCM token at boot so it's readable HEADLESSLY (adb logcat / appwrap
170
182
  // logs) without a UI tap — the dev loop needs the token to send a test push. Android only (iOS push
171
183
  // is off on personal teams); no-op when push isn't configured for this platform.
@@ -230,8 +242,11 @@ function androidGetToken(): Promise<PushToken> {
230
242
  const task = fcm().getToken();
231
243
  task.addOnCompleteListener(new OnCompleteListener({
232
244
  onComplete(t: any) {
233
- if (t.isSuccessful()) resolve({ platform: 'fcm', token: String(t.getResult()) });
234
- else reject(Object.assign(new Error('FCM token fetch failed'), { code: 'NATIVE_ERROR' }));
245
+ if (t.isSuccessful()) {
246
+ const tok = String(t.getResult());
247
+ registerTokenWithBackend('android', tok); // parity with iOS onApnsToken
248
+ resolve({ platform: 'fcm', token: tok });
249
+ } else reject(Object.assign(new Error('FCM token fetch failed'), { code: 'NATIVE_ERROR' }));
235
250
  },
236
251
  }));
237
252
  } catch (e: any) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "appwrap-shell",
3
3
  "main": "app/app.ts",
4
- "version": "0.28.0",
4
+ "version": "0.29.0",
5
5
  "private": true,
6
6
  "scripts": {
7
7
  "dev:ios": "ns run ios",
package/src/cli.ts CHANGED
@@ -409,7 +409,7 @@ function stampIOSDisplayName(outDir: string, cfg: AppwrapConfig, req: NativeReqs
409
409
  }
410
410
  if (cfg.urlScheme) {
411
411
  extras.push(
412
- ` <key>CFBundleURLTypes</key>\n <array>\n <dict>\n <key>CFBundleURLName</key>\n <string>${cfg.id}</string>\n <key>CFBundleURLSchemes</key>\n <array>\n <string>${cfg.urlScheme}</string>\n </array>\n </dict>\n </array>`
412
+ ` <key>CFBundleURLTypes</key>\n <array>\n <dict>\n <key>CFBundleTypeRole</key>\n <string>Editor</string>\n <key>CFBundleURLName</key>\n <string>${cfg.id}</string>\n <key>CFBundleURLSchemes</key>\n <array>\n <string>${cfg.urlScheme}</string>\n </array>\n </dict>\n </array>`
413
413
  );
414
414
  }
415
415
  if (extras.length) {