Flutter集成Moengage:iOS前台/后台点击推送不跳转指定链接求助
iOS端Moengage推送点击跳转异常排查要点
1. 原生端通知代理配置检查
在iOS原生代码(AppDelegate.swift/AppDelegate.m)中,必须确保Moengage的通知回调被正确接管:
- Swift环境:在
didFinishLaunchingWithOptions中设置UNUserNotificationCenter.current().delegate = self,同时实现userNotificationCenter(_:didReceive:withCompletionHandler:)方法,方法内调用MoEngage.sharedInstance().handleNotificationResponse(response, with: completionHandler)来让Moengage处理点击逻辑。 - Objective-C环境:对应实现
userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:,并调用[[MoEngage sharedInstance] handleNotificationResponse:response withCompletionHandler:completionHandler];
2. Deeplink基础配置验证
- 检查iOS项目
Info.plist中是否添加了与推送链接匹配的URL Scheme,这是deeplink跳转的必要前提。 - Flutter端初始化Moengage时,确认开启了deeplink处理开关(如
enableDeeplinkHandling: true,具体参数以当前SDK版本为准)。
3. 前台通知展示与回调设置
iOS默认前台不会弹出通知横幅,需做以下配置:
- 在
UNUserNotificationCenterDelegate的userNotificationCenter(_:willPresent:withCompletionHandler:)方法中,设置通知展示选项为.alert,确保前台能看到通知并触发点击回调。 - 若使用Moengage自定义前台通知样式,需确保通知视图绑定了deeplink点击事件,或者payload中的deeplink参数被正确解析传递。
4. 推送Payload格式校验
- 确认推送Payload中包含正确的deeplink参数(Moengage标准参数为
moengage_deeplink),值需为合法的自定义URL(如yourapp://target-page)。 - 若使用自定义通知样式,Payload中必须包含
mutable-content: 1,否则可能无法触发点击回调逻辑。
5. Flutter端路由逻辑检查
确保Flutter端已配置deeplink监听逻辑:
- 可通过Moengage自带的deeplink回调(如
onDeeplinkReceived事件),或第三方路由插件(如go_router)处理收到的deeplink,完成页面跳转。
内容的提问来源于stack exchange,提问作者Rhendy rivaldo
相关产品推荐
相关产品推荐

