fix(ios): forward APNs device token from AppDelegate to Capacitor
ROOT CAUSE of iOS push not working: Capacitor 7's default AppDelegate.swift template does NOT implement application(_:didRegisterForRemoteNotificationsWithDeviceToken:) or ...didFailToRegisterForRemoteNotificationsWithError:. So when @capacitor/push- notifications calls registerForRemoteNotifications(), iOS fetches the APNs token and calls the AppDelegate, but nothing posts .capacitorDidRegisterForRemoteNotifications, so the plugin never delivers the token to JS. register() 'succeeds' yet neither the registration nor registrationError event fires — proven by server push telemetry (register-called logged; no token, no error; device_tokens stayed empty). inject-push.js adds the two forwarding methods to the CI-generated AppDelegate (idempotent, tolerant — never fails the build), wired into ios-patch.sh after the audio patch. Verified against the real Capacitor 7 template: methods land inside the class, braces balance, both listeners present. This is the missing piece alongside the earlier aps-environment entitlement fix and the server APNs config. Needs a fresh Codemagic build to take effect. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -94,6 +94,10 @@ AD="mobile/ios/App/App/AppDelegate.swift"
|
||||
if [ -f "$AD" ]; then
|
||||
echo "Patching AppDelegate audio session"
|
||||
node "$(dirname "$0")/inject-audio.js" "$AD" || echo " (AVAudioSession patch skipped — non-fatal)"
|
||||
# Capacitor 7's AppDelegate template omits the APNs registration callbacks, so the push-notifications
|
||||
# plugin never receives the device token (register() fires no event at all). Inject the forwarding methods.
|
||||
echo "Patching AppDelegate APNs registration forwarding"
|
||||
node "$(dirname "$0")/inject-push.js" "$AD" || echo " (push forwarding patch skipped — non-fatal)"
|
||||
fi
|
||||
|
||||
echo "Info.plist patched:"
|
||||
|
||||
Reference in New Issue
Block a user