0
votes

I'm pulling my hair out because I've triple checked and the following is True:

  1. App delegate is setup (and now bloated)
  2. APNs have been created signed and uploaded to apple downloaded keyed and uploaded to google
  3. App has remote notifications toggled.

here is the app delegate:

import SwiftUI
import AVKit
import UIKit
import AVFoundation
import Firebase
import FirebaseMessaging
import UserNotifications

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    let audioSession = AVAudioSession.sharedInstance()
    
    do {
        try audioSession.setCategory(AVAudioSession.Category.playback)
    } catch  {
        print("Audio session failed")
    }
    
    FirebaseApp.configure()
    
    application.registerForRemoteNotifications()
    
    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)
    }
    
    Messaging.messaging().delegate = self

        UNUserNotificationCenter.current()
            .requestAuthorization(options: [.alert, .sound, .badge]) {granted, error in

                print("Permission granted: \(granted)")
        }

        UNUserNotificationCenter.current().delegate = self

        application.registerForRemoteNotifications()

    application.registerForRemoteNotifications()

    Messaging.messaging().delegate = self
    
    return true
}

func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {

    print("FCM Token Is: \(fcmToken)")
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

    print("Token is: \(deviceToken)")
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {

    print("Error is \(error)")
}


// MARK: - UISceneSession

func application(_ application: UIApplication,
                 configurationForConnecting connectingSceneSession: UISceneSession,
                 options: UIScene.ConnectionOptions) -> UISceneConfiguration {
    // Called when a new scene session is being created.
    // Use this method to select a configuration to create the new scene with.
    UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication,
                 didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
    // Called when the user discards a scene session.
    // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

And the error log:

2020-10-07 12:25:57.235303-0500 Project[1428:310502] 6.34.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at: https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging to ensure proper integration.

2020-10-07 12:25:57.249142-0500 Project[1428:310493] 6.34.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60900000 started

2020-10-07 12:25:57.249750-0500 Project[1428:310493] 6.34.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled

Error is 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}

2020-10-07 12:25:57.343208-0500 Project[1428:310500] 6.34.0 - [Firebase/Messaging][I-FCM012002] Error in application:didFailToRegisterForRemoteNotificationsWithError: no valid “aps-environment” entitlement string found for application

2020-10-07 12:25:57.350290-0500 Project[1428:310500] Metal API Validation Enabled

2020-10-07 12:25:57.476988-0500 Project[1428:310502] 6.34.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement

2020-10-07 12:25:57.477541-0500 Project[1428:310502] 6.34.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled

2020-10-07 12:25:57.477668-0500 Project[1428:310502] 6.34.0 - [Firebase/Analytics][I-ACS023220] Analytics screen reporting is enabled. Call +[FIRAnalytics logEventWithName:FIREventScreenView parameters:] to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist

2
firebase.google.com/docs/cloud-messaging/ios/… This is the official documentation I was referring toRealTechyGod

2 Answers

0
votes

a simple update to Xcode 12.2 (beta 2) Command lines fixed the issue for whatever reason

0
votes

I face with the same issue and after a few hours of research, I found the answer for my case. In Target at Build Setting, find the key "CODE_SIGN_ENTITLEMENTS" and point it to the ".entitlements" file.

enter image description here