iOS: defer notification permission prompt until registerPush / scheduleLocalNotification#4894
Open
shai-almog wants to merge 1 commit intomasterfrom
Open
iOS: defer notification permission prompt until registerPush / scheduleLocalNotification#4894shai-almog wants to merge 1 commit intomasterfrom
shai-almog wants to merge 1 commit intomasterfrom
Conversation
…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>
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Contributor
|
Developer Guide build artifacts are available for download from this workflow run:
Developer Guide quality checks:
Unused image preview:
|
Collaborator
Author
|
Compared 90 screenshots: 90 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Contributor
Cloudflare Preview
|
Collaborator
Author
|
Compared 90 screenshots: 90 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 90 screenshots: 90 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
requestAuthorizationWithOptionsfromapplication:didFinishLaunchingWithOptions:, so the system permission dialog no longer fires at launch as soon asios.includePush=trueis set. The auth prompt is now triggered on the firstPush.register()(already requested permission insideIOSNative.m) or on the firstLocalNotification.schedule()call (newrequestAuthorizationWithOptionsadded insendLocalNotification). This matches the Android flow, wherePOST_NOTIFICATIONSis requested only whenregisterPush()/scheduleLocalNotification()runs, and lets the developer show a rationale screen first.ios.notificationPermissionAtLaunch=true(defaultfalse) restores the legacy launch-time prompt by uncommenting a newCN1_NOTIFICATION_PERMISSION_AT_LAUNCHmacro inCodenameOne_GLAppDelegate.h. The macro guards a re-introducedrequestAuthorizationWithOptionsblock inCodenameOne_GLAppDelegate.m. Mirrors the cloud-side change shipped in BuildDaemon#71.Advanced-Topics-Under-The-Hood.asciidoc) and in the push registration lifecycle section (Push-Notifications.asciidoc).Test plan
codename1.arg.ios.includePush=true, noPush.register()call: confirm the system notification permission alert no longer appears on first launch.Push.register()from a button handler: confirm the system permission alert now appears at that point.LocalNotificationonly (no push): confirm the permission alert appears on firstLocalNotification.schedule()and the notification fires once granted.codename1.arg.ios.notificationPermissionAtLaunch=trueto an existing app: confirm the legacy launch-time prompt is restored.CN1_NOTIFICATION_PERMISSION_AT_LAUNCHends up#defined (not//#define) in the patchedCodenameOne_GLAppDelegate.honly when the build hint is set.🤖 Generated with Claude Code