在应用程序功能下的Xcode中,有一个选项可以打开“推送通知”。在“后台模式”下,还有一个选项可以打开“远程通知”。有什么不同?优点缺点?
我是否仍为远程通知设置推送证书?
将Xcode版本更新为8.0后,我收到此错误.在尝试注册远程通知时,我可以在我的日志中看到这样的内容
Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo={NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}, no valid 'aps-environment' entitlement string found for application
Run Code Online (Sandbox Code Playgroud)
我尝试了一些与我的问题相关的Stack Overflow答案,但无法解决这个问题.
1.处理新的临时简介
2.删除并重新安装应用程序
3.手动设置临时配置文件.
以上任何一项都没有帮助我解决.
请给我一些建议.提前致谢.
我正在尝试使用Firebase将推送通知应用到我的应用程序中,但是在遵循他们的文档时,我必须添加以下代码行:
if #available(iOS 10.0, *) {
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(options: authOptions, completionHandler: {_, _ in})
UNUserNotificationCenter.current().delegate = self
FIRMessaging.messaging().remoteMessageDelegate = self
} else {
let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
Run Code Online (Sandbox Code Playgroud)
添加此代码后,应用程序将无法编译,并且会向我发出错误,让我知道我
不能分配类型的值
AppDelegate输入FirMessagingDelegate
那个我
无法指定AppDelegate类型的值来键入UNUserNotificationCenterDelegate.
所以很自然地,我添加了FIRMessagingDelegate和UNUserNotificationCenterDelegate我的应用程序,但是FIRMessagingDelegate不允许应用程序编译说
类型AppDelegate不符合协议'FirMessagingDelegate'.
有任何想法吗?我还没有设法找到其他人遇到此错误的其他情况,而在Google的文档中,这两个代表甚至都没有添加.
ios firebase swift3 remote-notifications firebase-cloud-messaging
所以我更新了firebase_messaging并且我不得不更改我的代码,因为FirebaseMessagin.configure()它已被弃用,现在当我收到通知并单击通知时,它不会打开另一个屏幕。
这就是我实现通知的方式:
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
print('Handling a background message ${message.messageId}');
}
const AndroidNotificationChannel channel = AndroidNotificationChannel(
'high_importance_channel', // id
'High Importance Notifications', // title
'This channel is used for important notifications.', // description
importance: Importance.high,
);
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'e-R?d?u?i',
debugShowCheckedModeBanner: false,
initialRoute: …Run Code Online (Sandbox Code Playgroud) android push-notification flutter remote-notifications firebase-cloud-messaging