You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ionic 3中PhoneGap推送插件报错:senderID缺失及options常量问题求助

Fixing 'senderID Missing' and Type Error with phonegap-push-plugin in Ionic 3 + PhoneGap

Got it, let's tackle these two issues you're facing—they're actually pretty common when setting up push notifications with this stack, even if you followed the official docs. Here's what you need to do:

1. Resolve the 'senderID is Missing' Error

The official docs might have omitted a critical detail: the Android platform requires a senderID (this is your Firebase Cloud Messaging project number) to work properly. Without it, the plugin throws that missing senderID error every time.

Update your options object to include the senderID in the Android config:

const options: PushOptions = {
  android: {
    senderID: '1234567890' // Replace this with your Firebase project's sender ID
  },
  ios: { alert: 'true', badge: true, sound: 'false' },
  windows: {},
  browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }
};

To get your senderID:

  • Open your Firebase project dashboard, navigate to Settings > Cloud Messaging, and copy the "Sender ID" value listed there.

2. Fix the Type Error Hovering Over options

This is a TypeScript type mismatch issue. The PushOptions interface from @ionic-native/push expects the android property to include a senderID—since you were missing it before, TypeScript flags it as an error.

Once you add the senderID as above, this error should disappear automatically. But if it persists, double-check your dependency versions to ensure compatibility with Ionic 3:

  • Uninstall any incompatible versions first:
    npm uninstall @ionic-native/push
    cordova plugin remove phonegap-plugin-push
    
  • Reinstall versions that work with Ionic 3:
    npm install @ionic-native/push@4.x --save
    cordova plugin add phonegap-plugin-push@2.x --save
    

Ionic 3 relies on version 4.x of @ionic-native packages, and phonegap-plugin-push 2.x is the last stable release compatible with this setup.

After making these changes, rebuild your project (ionic cordova build android or ios) and the errors should be gone.

内容的提问来源于stack exchange,提问作者user3397260

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:35:29