Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS快速推送通知_Ios_Swift_Xcode - Fatal编程技术网

iOS快速推送通知

iOS快速推送通知,ios,swift,xcode,Ios,Swift,Xcode,我正在制作一个应用程序来接收通知。我遵循了一些教程,制作了一个示例应用程序。我还将其配置为在收到通知时显示警报、徽章和声音 我还完成了所有的firebase配置,然后我启动了iphone7模拟器 现在我正在尝试使用firebase发送消息。该消息是从firebase发送的。我在Xcode的调试窗口中也看到了收到的消息,但该消息在模拟器上根本没有显示为警报 我在某个地方读到推送通知不适用于模拟器,所以我附加了一个内置并运行iOS9.0的iPhone设备 现在,我甚至在调试窗口中也看不到消息。 请帮

我正在制作一个应用程序来接收通知。我遵循了一些教程,制作了一个示例应用程序。我还将其配置为在收到通知时显示警报、徽章和声音

我还完成了所有的firebase配置,然后我启动了iphone7模拟器

现在我正在尝试使用firebase发送消息。该消息是从firebase发送的。我在Xcode的调试窗口中也看到了收到的消息,但该消息在模拟器上根本没有显示为警报

我在某个地方读到推送通知不适用于模拟器,所以我附加了一个内置并运行iOS9.0的iPhone设备

现在,我甚至在调试窗口中也看不到消息。 请帮助我如何测试推送通知

以下是我的代码的链接:

如果您的应用程序是前台应用程序,则无法收到通知

对于iOS 10,您需要集成willPresentNotification方法,以便在前台显示通知横幅

如果应用程序处于前台模式(活动)


如果您的appp是前台,则不会显示,firebase控制台中的输出/结果是什么?firebase显示“已完成”。正如我所说,当我在模拟器中运行同一程序时,Xcode调试窗口显示收到消息,但当我在真实设备上运行时,同一调试窗口和同一程序没有显示任何内容。我没有收到任何内容-无论是前台还是后台Func userNotificationCenter(center:UNUserNotificationCenter,将呈现通知:UNNotification,withCompletionHandler completionHandler:@escaping(UNNotificationPresentationOptions)->Void){let userInfo=notification.request.content.userInfo如果let messageID=userInfo[gcmMessageIDKey]{print(“消息ID:(messageID)”)}print(userInfo)completionHandler([.alert、.sound、.badge])]我是否应该在app Store中加载应用程序,然后分发以进行测试,以便测试此功能。直接将手机连接到Xcode并执行run命令是否不起作用。请给出建议。有疑问的是,iOS版本是9.0,所以要接收该通知,您需要method
应用程序(uApplication:UIApplication,DidReceivereMotentification数据:[AnyHashable:Any])
- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
    NSLog( @“Handle push notification in foreground" ); 
    //For notification Banner - when app in foreground

    completionHandler(UNNotificationPresentationOptionAlert);

    // Print Notification info
    NSLog(@"info %@",notification.request.content.userInfo);
}