我们使用 React Native 制作了移动应用程序。 在此我们使用以下库来进行推送通知。
“@react-native-community/push-notification-ios”:“^1.11.0”, “反应本机推送通知”:“8.1.1”,
现在我们要修改ios应用程序中的远程通知正文内容。
在ios应用程序中,我们尝试添加通知服务扩展,但不起作用。当获取通知时,不会调用通知服务扩展方法,并且在为服务扩展创建的演示应用程序中工作的内容相同。
服务延伸方法:-
我们在 Appdelegate didfinishlanuch 方法中定义以下内容:-
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound + UNAuthorizationOptionBadge)completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (granted) {
center.delegate = self;
}
}];
所以任何人有解决方案请帮助我们。
谢谢你
Shraddha vaishnani
您必须在通知服务器中发送仅数据通知(没有标题和消息)。虽然后台通知不会显示,但远程通知将会到达。然后,您应该使用react-native-push-notification来提示带有自定义标题和消息的本地通知。