0

このアプリケーションには何もありません。通知のためFirebaseと接続しました。 私のコードは、これは私がSwift3:リモート通知を受け取りません

2017-08-28 19:37:01.204266-0400 newnotifica3[28588:10713078] [Firebase/Analytics][I-ACS003016] Firebase Analytics App Delegate Proxy is disabled. To log deep link campaigns manually, call the methods in FIRAnalytics+AppDelegate.h. 
2017-08-28 19:37:01.204 newnotifica3[28588] <Warning> [Firebase/Analytics][I-ACS003016] Firebase Analytics App Delegate Proxy is disabled. To log deep link campaigns manually, call the methods in FIRAnalytics+AppDelegate.h. 
2017-08-28 19:37:01.264081-0400 newnotifica3[28588:10713076] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.4001000 started 
2017-08-28 19:37:01.264 newnotifica3[28588] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.4001000 started 
2017-08-28 19:37:01.264507-0400 newnotifica3[28588:10713076] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see) 
2017-08-28 19:37:01.264 newnotifica3[28588] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see) 
FCM token: fstLqWX6ZjA:APA91bE6PovZpdgL0l0AcsEcL_rXn1heAcNLzG6rQhIxMflkVRz32OcAilYN5-bpLNrYTaKK5xtzfdHrfU63T9Tpkb-SG2_mx8-YYtbwlQUyGWxG4V_QuozNVUVNq9EH-BstecIFgaTZ 
APNs token retrieved: 32 bytes 
2017-08-28 19:37:01.305018-0400 newnotifica3[28588:10713081] [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled 
2017-08-28 19:37:01.305 newnotifica3[28588] <Notice> [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled 
2017-08-28 19:37:01.315306-0400 newnotifica3[28588:10713076] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 
2017-08-28 19:37:01.316763-0400 newnotifica3[28588:10713076] [MC] Reading from public effective user settings. 

私はときに最初にインストールが、私はfirebaseから通知やメッセージを送信する場合は、手動でそれが働いているかどうかを確認するかの通知を許可することができ、コンソールに取得していますものです

import UIKit 
import UserNotifications 
import FirebaseMessaging 
import Firebase 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 
    let gcmMessageIDKey = "gcm.message_id" 

    func application(_ application: UIApplication, 
        didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 

     FirebaseApp.configure() 

     // [START set_messaging_delegate] 
     Messaging.messaging().delegate = self 
     // [END set_messaging_delegate] 
     // Register for remote notifications. This shows a permission dialog on first run, to 
     // show the dialog at a more appropriate time move this registration accordingly. 
     // [START register_for_notifications] 
     if #available(iOS 10.0, *) { 
      // For iOS 10 display notification (sent via APNS) 
      UNUserNotificationCenter.current().delegate = self 

      let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] 
      UNUserNotificationCenter.current().requestAuthorization(
       options: authOptions, 
       completionHandler: {_, _ in }) 
     } else { 
      let settings: UIUserNotificationSettings = 
       UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) 
      application.registerUserNotificationSettings(settings) 
     } 

     application.registerForRemoteNotifications() 

     // [END register_for_notifications] 
     return true 
    } 

    // [START receive_message] 
    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { 
     // If you are receiving a notification message while your app is in the background, 
     // this callback will not be fired till the user taps on the notification launching the application. 
     // TODO: Handle data of notification 
     // With swizzling disabled you must let Messaging know about the message, for Analytics 
     // Messaging.messaging().appDidReceiveMessage(userInfo) 
     // Print message ID. 
     if let messageID = userInfo[gcmMessageIDKey] { 
      print("Message ID: \(messageID)") 
     } 

     // Print full message. 
     print(userInfo) 
    } 

    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], 
        fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { 
     // If you are receiving a notification message while your app is in the background, 
     // this callback will not be fired till the user taps on the notification launching the application. 
     // TODO: Handle data of notification 
     // With swizzling disabled you must let Messaging know about the message, for Analytics 
     // Messaging.messaging().appDidReceiveMessage(userInfo) 
     // Print message ID. 
     if let messageID = userInfo[gcmMessageIDKey] { 
      print("Message ID: \(messageID)") 
     } 

     // Print full message. 
     print(userInfo) 

     completionHandler(UIBackgroundFetchResult.newData) 
    } 
    // [END receive_message] 
    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { 
     print("Unable to register for remote notifications: \(error.localizedDescription)") 
    } 

    // This function is added here only for debugging purposes, and can be removed if swizzling is enabled. 
    // If swizzling is disabled then this function must be implemented so that the APNs token can be paired to 
    // the FCM registration token. 
    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { 
     print("APNs token retrieved: \(deviceToken)") 

     // With swizzling disabled you must set the APNs token here. 
     // Messaging.messaging().apnsToken = deviceToken 
    } 
} 

// [START ios_10_message_handling] 
@available(iOS 10, *) 
extension AppDelegate : UNUserNotificationCenterDelegate { 

    // Receive displayed notifications for iOS 10 devices. 
    func userNotificationCenter(_ center: UNUserNotificationCenter, 
           willPresent notification: UNNotification, 
           withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { 
     let userInfo = notification.request.content.userInfo 

     // With swizzling disabled you must let Messaging know about the message, for Analytics 
     // Messaging.messaging().appDidReceiveMessage(userInfo) 
     // Print message ID. 
     if let messageID = userInfo[gcmMessageIDKey] { 
      print("Message ID: \(messageID)") 
     } 

     // Print full message. 
     print(userInfo) 

     // Change this to your preferred presentation option 
     completionHandler([]) 
    } 

    func userNotificationCenter(_ center: UNUserNotificationCenter, 
           didReceive response: UNNotificationResponse, 
           withCompletionHandler completionHandler: @escaping() -> Void) { 
     let userInfo = response.notification.request.content.userInfo 
     // Print message ID. 
     if let messageID = userInfo[gcmMessageIDKey] { 
      print("Message ID: \(messageID)") 
     } 

     // Print full message. 
     print(userInfo) 

     completionHandler() 
    } 
} 
// [END ios_10_message_handling] 

extension AppDelegate : MessagingDelegate { 
    // [START refresh_token] 
    func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) { 
     print("Firebase registration token: \(fcmToken)") 
    } 
    // [END refresh_token] 
    // [START ios_10_data_message] 
    // Receive data messages on iOS 10+ directly from FCM (bypassing APNs) when the app is in the foreground. 
    // To enable direct data messages, you can set Messaging.messaging().shouldEstablishDirectChannel to true. 
    func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) { 
     print("Received data message: \(remoteMessage.appData)") 
    } 
    // [END ios_10_data_message] 
} 

ですそうではありませんが、私のメッセージがコンソールでも電話でもうまく送信されないことがわかります。

私を助けてください。

+0

いつの間にか前もってすべてがうまく動作していますが、今は何が起こったのか分かりません。手作業でも通知を停止します...私を助けてください –

答えて

0

APNS deviceTokenの取得方法にいくつかの変更があります。

関連する問題