Skip to content

iOS: defer notification permission prompt until registerPush / scheduleLocalNotification#4894

Open
shai-almog wants to merge 1 commit intomasterfrom
fix/ios-notification-permission-on-demand
Open

iOS: defer notification permission prompt until registerPush / scheduleLocalNotification#4894
shai-almog wants to merge 1 commit intomasterfrom
fix/ios-notification-permission-on-demand

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes Possibility to implement PushNotification in other Class instead Main Class automatically. #4876. iOS no longer calls requestAuthorizationWithOptions from application:didFinishLaunchingWithOptions:, so the system permission dialog no longer fires at launch as soon as ios.includePush=true is set. The auth prompt is now triggered on the first Push.register() (already requested permission inside IOSNative.m) or on the first LocalNotification.schedule() call (new requestAuthorizationWithOptions added in sendLocalNotification). This matches the Android flow, where POST_NOTIFICATIONS is requested only when registerPush() / scheduleLocalNotification() runs, and lets the developer show a rationale screen first.
  • Backward-compatibility build hint ios.notificationPermissionAtLaunch=true (default false) restores the legacy launch-time prompt by uncommenting a new CN1_NOTIFICATION_PERMISSION_AT_LAUNCH macro in CodenameOne_GLAppDelegate.h. The macro guards a re-introduced requestAuthorizationWithOptions block in CodenameOne_GLAppDelegate.m. Mirrors the cloud-side change shipped in BuildDaemon#71.
  • Documented the new behavior in the iOS build hints table (Advanced-Topics-Under-The-Hood.asciidoc) and in the push registration lifecycle section (Push-Notifications.asciidoc).

Test plan

  • Build an iOS app with codename1.arg.ios.includePush=true, no Push.register() call: confirm the system notification permission alert no longer appears on first launch.
  • Same build, call Push.register() from a button handler: confirm the system permission alert now appears at that point.
  • Build an iOS app that uses LocalNotification only (no push): confirm the permission alert appears on first LocalNotification.schedule() and the notification fires once granted.
  • Add codename1.arg.ios.notificationPermissionAtLaunch=true to an existing app: confirm the legacy launch-time prompt is restored.
  • Verify CN1_NOTIFICATION_PERMISSION_AT_LAUNCH ends up #defined (not //#define) in the patched CodenameOne_GLAppDelegate.h only when the build hint is set.

🤖 Generated with Claude Code

…dLocalNotification (#4876)

Previously the iOS app delegate called requestAuthorizationWithOptions in
didFinishLaunchingWithOptions whenever notifications were enabled, so the
system prompt fired at launch before the developer could show their own
rationale screen. Match the Android flow by setting only the notification
center delegate at launch, and request authorization on the first call to
registerPush() or sendLocalNotification(). For backward compatibility add
the ios.notificationPermissionAtLaunch=true build hint, which gates a
CN1_NOTIFICATION_PERMISSION_AT_LAUNCH macro that restores the legacy
launch-time prompt.

Documented the new behavior and build hint in the iOS build hints table
and the push notifications guide.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

✅ Continuous Quality Report

Test & Coverage

Static Analysis

  • SpotBugs [Report archive]
    • ByteCodeTranslator: 0 findings (no issues)
    • android: 0 findings (no issues)
    • codenameone-maven-plugin: 0 findings (no issues)
    • core-unittests: 0 findings (no issues)
    • ios: 0 findings (no issues)
  • PMD: 0 findings (no issues) [Report archive]
  • Checkstyle: 0 findings (no issues) [Report archive]

Generated automatically by the PR CI workflow.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Developer Guide build artifacts are available for download from this workflow run:

Developer Guide quality checks:

  • AsciiDoc linter: No issues found (report)
  • Vale: Vale failed (exit code 2) (report)
  • Image references: 1 unused image(s) found (report)

Unused image preview:

  • img/skin-designer/.gitkeep

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 8, 2026

Compared 90 screenshots: 90 matched.

Native Android coverage

  • 📊 Line coverage: 10.18% (5555/54579 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 7.99% (27212/340606), branch 3.66% (1196/32646), complexity 4.68% (1464/31272), method 8.22% (1202/14614), class 13.59% (267/1964)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 10.18% (5555/54579 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 7.99% (27212/340606), branch 3.66% (1196/32646), complexity 4.68% (1464/31272), method 8.22% (1202/14614), class 13.59% (267/1964)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 880.000 ms
Base64 CN1 encode 157.000 ms
Base64 encode ratio (CN1/native) 0.178x (82.2% faster)
Base64 native decode 734.000 ms
Base64 CN1 decode 209.000 ms
Base64 decode ratio (CN1/native) 0.285x (71.5% faster)
Image encode benchmark status skipped (SIMD unsupported)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Cloudflare Preview

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 8, 2026

Compared 90 screenshots: 90 matched.
✅ Native iOS Metal screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 339 seconds

Build and Run Timing

Metric Duration
Simulator Boot 95000 ms
Simulator Boot (Run) 1000 ms
App Install 16000 ms
App Launch 7000 ms
Test Execution 245000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1829.000 ms
Base64 CN1 encode 2090.000 ms
Base64 encode ratio (CN1/native) 1.143x (14.3% slower)
Base64 native decode 1494.000 ms
Base64 CN1 decode 1403.000 ms
Base64 decode ratio (CN1/native) 0.939x (6.1% faster)
Base64 SIMD encode 596.000 ms
Base64 encode ratio (SIMD/native) 0.326x (67.4% faster)
Base64 encode ratio (SIMD/CN1) 0.285x (71.5% faster)
Base64 SIMD decode 1014.000 ms
Base64 decode ratio (SIMD/native) 0.679x (32.1% faster)
Base64 decode ratio (SIMD/CN1) 0.723x (27.7% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 70.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.129x (87.1% faster)
Image applyMask (SIMD off) 161.000 ms
Image applyMask (SIMD on) 88.000 ms
Image applyMask ratio (SIMD on/off) 0.547x (45.3% faster)
Image modifyAlpha (SIMD off) 172.000 ms
Image modifyAlpha (SIMD on) 102.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.593x (40.7% faster)
Image modifyAlpha removeColor (SIMD off) 178.000 ms
Image modifyAlpha removeColor (SIMD on) 152.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.854x (14.6% faster)
Image PNG encode (SIMD off) 1851.000 ms
Image PNG encode (SIMD on) 1228.000 ms
Image PNG encode ratio (SIMD on/off) 0.663x (33.7% faster)
Image JPEG encode 839.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 8, 2026

Compared 90 screenshots: 90 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 223 seconds

Build and Run Timing

Metric Duration
Simulator Boot 92000 ms
Simulator Boot (Run) 1000 ms
App Install 12000 ms
App Launch 3000 ms
Test Execution 237000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1486.000 ms
Base64 CN1 encode 1353.000 ms
Base64 encode ratio (CN1/native) 0.910x (9.0% faster)
Base64 native decode 765.000 ms
Base64 CN1 decode 895.000 ms
Base64 decode ratio (CN1/native) 1.170x (17.0% slower)
Base64 SIMD encode 440.000 ms
Base64 encode ratio (SIMD/native) 0.296x (70.4% faster)
Base64 encode ratio (SIMD/CN1) 0.325x (67.5% faster)
Base64 SIMD decode 368.000 ms
Base64 decode ratio (SIMD/native) 0.481x (51.9% faster)
Base64 decode ratio (SIMD/CN1) 0.411x (58.9% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 57.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.158x (84.2% faster)
Image applyMask (SIMD off) 119.000 ms
Image applyMask (SIMD on) 56.000 ms
Image applyMask ratio (SIMD on/off) 0.471x (52.9% faster)
Image modifyAlpha (SIMD off) 115.000 ms
Image modifyAlpha (SIMD on) 53.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.461x (53.9% faster)
Image modifyAlpha removeColor (SIMD off) 138.000 ms
Image modifyAlpha removeColor (SIMD on) 62.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.449x (55.1% faster)
Image PNG encode (SIMD off) 978.000 ms
Image PNG encode (SIMD on) 786.000 ms
Image PNG encode ratio (SIMD on/off) 0.804x (19.6% faster)
Image JPEG encode 425.000 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possibility to implement PushNotification in other Class instead Main Class automatically.

1 participant