求助:Ionic应用Xcode模拟器收不到推送,提示需为App ID加推送功能
解决Xcode Push Notification报错及Ionic应用模拟器接收推送问题
Hey there, let's walk through fixing this issue step by step—your error message is pointing straight to the root problem: your App ID doesn't have the push notification feature enabled yet. Here's how to get this sorted:
1. 先在苹果开发者后台开启App ID的推送权限
This is the critical first step since Xcode is explicitly telling you to add push notifications to your App ID:
- Log into your Apple Developer Account, navigate to Certificates, Identifiers & Profiles.
- Select Identifiers from the left sidebar, then find the App ID tied to your Ionic app.
- Click the Edit button for that App ID.
- Scroll down to the Capabilities section, check the box next to Push Notifications.
- Hit Save at the bottom of the page to lock in this change.
2. 更新Xcode项目配置
Now that your App ID is properly set up, let's get Xcode to recognize the update:
- Close Xcode completely (don't just minimize it) and reopen your Ionic project's
.xcworkspacefile. - Navigate to your project's Signing & Capabilities tab. If the Push Notifications section still shows an error, click the + Capability button in the top-left corner, search for Push Notifications, and add it to your project.
- Double-check that your auto-generated
Entitlements.plistfile includes theaps-environmentkey, with a value ofdevelopment—since simulators only work with the sandbox environment.
3. 确认Ionic推送插件配置
Make sure your Ionic project is set up to handle push notifications correctly:
- If you're using Capacitor, confirm you've installed
@capacitor/push-notificationsand runnpx cap syncto sync the plugin with your Xcode project. - For Cordova users, stick with a maintained push plugin like
cordova-plugin-fcm-with-dependency-updated, and verify yourconfig.xmluses the exact bundle ID matching your App ID.
4. 模拟器接收推送的关键注意事项
Simulators have specific rules for push notifications—don't overlook these:
- Your simulator must run iOS 13 or later (older versions don't support push notifications at all).
- First, retrieve the simulator's device token (your Ionic app should log this when initializing push notifications).
- To test, use Apple's sandbox push server. You can send a test push via curl (replace placeholders with your own details):
curl -X POST "https://api.sandbox.push.apple.com/3/device/[SIMULATOR_DEVICE_TOKEN]" \ -H "apns-topic: [YOUR_APP_BUNDLE_ID]" \ -H "apns-push-type: alert" \ -H "apns-expiration: 0" \ -H "apns-priority: 10" \ -H "Authorization: bearer [YOUR_AUTH_TOKEN]" \ -d '{"aps":{"alert":"Test Push Notification","sound":"default"}}' - Ensure your push certificate is for the development/sandbox environment—simulators can't receive production pushes.
常见排查点
If you still can't receive pushes after these steps:
- Verify your Xcode project's Signing settings use the correct team and development certificate (matching the one linked to your App ID).
- Double-check that the device token you're using is from the simulator (it will look different from a real device's token).
- Check the Xcode console (Window > Devices and Simulators > Select your simulator > Open Console) for any push-related error messages when sending a notification.
内容的提问来源于stack exchange,提问作者Íñigo Enrique Hernández
相关产品推荐
相关产品推荐

