I am receiving a “No such module ‘FirebaseUI’”
I have an app where I am trying to subclass from FirebaseAppDelegate and I am getting an error. I am using the docs at:
http://cocoadocs.org/docsets/FirebaseUI/0.3.2/
============================================
The sample code in that link shows the following swift code:
import UIKit
import FirebaseUI
#UIApplicationMain
class AppDelegate: FirebaseAppDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
super.application(application, launchOptions);
// Override point for customization after application launch.
return true
}
============================================
My app has the following code:
import UIKit
import Firebase
import FirebaseAuthUI
import FirebaseUI
#UIApplicationMain
class AppDelegate: FirebaseAppDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}
in my Podfile I have the following:
target 'FBLogin' do
use_frameworks!
pod 'FirebaseUI'
pod 'Firebase'
end
I ran 'pod install' without issues.
============================================
I also downloaded the sample code at:
https://github.com/firebase/FirebaseUI-iOS
I searched for “FirebaseAppDelegate” and could not find a reference to that text in the sample code project.
Note that I had other components of FirebaseUI already working in my app. It wasn't until I tried to subclass from FirebaseAppDelegate that I started having build issues.
Related
I have issue with OneSignal push notifications for iOS app after I added Firebase Auth with phone. All iOS devices listed in OneSignal are marked with "Apns Delegate Never Fired" label and notifications can be sended but app don't receive them.
I found two similar issues that
https://github.com/OneSignal/OneSignal-iOS-SDK/issues/790
https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/245
As I understand the problem might be with swizzling that is used by Firebase Auth.
I disabled swizzling using info.plist file as it suggested in the official firebase docs. But issue remains, so I think that I am missing something and OneSignal SDK still not being called.
My AppDelegate file looks like
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.unknown)
}
override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult) -> Void) {
if Auth.auth().canHandleNotification(userInfo) {
completionHandler(.noData)
return
}
}
I am trying to implement phone auth in SwiftUI using Firebase. I keep getting the following error in the console:
If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotificaton: method.
I have not disabled swizzling from what I know and I have tried different things.
I set-up my firebase project correctly, anyone else facing the same problem?
I looked up in the documentation and I found a part about this:
func application(_ application: UIApplication,
didReceiveRemoteNotification notification: [AnyHashable : Any],
fetchCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult) -> Void) {
if Auth.auth().canHandleNotification(notification) {
completionHandler(.noData)
return
}
// This notification is not auth related, developer should handle it.
}
But I don't know where to put it or how to declare it.
Tried doing the following but nothing changes:
import SwiftUI
import Firebase
import GoogleMaps
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didReceiveRemoteNotification notification: [AnyHashable : Any],
fetchCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult) -> Void) {
if Auth.auth().canHandleNotification(notification) {
completionHandler(.noData)
return
}
// This notification is not auth related, developer should handle it.
}
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
for urlContext in URLContexts {
let url = urlContext.url
Auth.auth().canHandle(url)
}
// URL not auth related, developer should handle it.
}
}
#main
struct partidulverdeApp: App {
#UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
init() {
FirebaseApp.configure()
GMSServices.provideAPIKey("AIzaSyAaze5cpEcJUgw2WFgLhlTWYr9ZP4fyDNk")
}
var body: some Scene {
WindowGroup {
MainView()
.onOpenURL(perform: { url in
Auth.auth().canHandle(url)
})
}
}
}
I registered for a free account at HERE to try out their iOS starter. I downloaded their sample from https://github.com/heremaps/here-ios-sdk-examples and trying to build turn-by-turn-navigation-ios-swift. I have added the appid and appcode from their developer website (screenshot below)
However, to initialize the HERE service you are required to provide a license key as well.
import UIKit
import NMAKit
let credentials = (
appId: "I have this",
appCode: "I have this",
licenseKey: "Can't find this"
)
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
NMAApplicationContext.setAppId(credentials.appId, appCode: credentials.appCode, licenseKey: credentials.licenseKey)
return true
}
}
Could someone please point me in the correct direction in which I could find the license key?
Thanks!
Don't think starter SDK supports Navigation as per: https://developer.here.com/develop/mobile-sdks
Only premium SDK supports navigation use-case and uses the license key to gate the feature usage.
Hi I'm using XCode version: 10.1 (10B61) and iPhone SE with iOS version: 12.0.1 (16A404), I installed properly all configuration as documentation explained, I uploaded the Auth .p8 certificate and the p.12 certificates of development and production, but when I try to send a push notification from Firebase console I don't receive any, am I missing something? or I did some wrong? any help, please?
//
// AppDelegate.swift
// SpriteKit Game Demo
//
// Created by Dennis Mostajo on 9/2/18.
// Copyright © 2018 Mostys Studios.. All rights reserved.
//
import UIKit
import Fabric
import Crashlytics
import Firebase
import UserNotifications
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{
var window: UIWindow?
var navigationVC: UINavigationController?
let gcmMessageIDKey = "gcm.message_id"
override init() {
// set Firebase configuration
FirebaseApp.configure()
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
debugPrint("didFinishLaunchingWithOptions")
Fabric.with([Crashlytics.self])
DataBaseHelper.DBUpdate() // Run migrations
// Enable Push Notifications
Messaging.messaging().delegate = self
Messaging.messaging().shouldEstablishDirectChannel = true
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()
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
debugPrint("applicationWillResignActive")
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
debugPrint("applicationDidEnterBackground")
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
debugPrint("applicationWillEnterForeground")
}
func applicationDidBecomeActive(_ application: UIApplication)
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
debugPrint("applicationDidBecomeActive")
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
debugPrint("applicationWillTerminate")
}
// MARK: - FIREBASE
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any])
{
Messaging.messaging().appDidReceiveMessage(userInfo)
if let messageID = userInfo[gcmMessageIDKey]
{
debugPrint("Message ID: \(messageID)")
}
// Print full message.
debugPrint(userInfo)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult) -> Void)
{
Messaging.messaging().appDidReceiveMessage(userInfo)
if let messageID = userInfo[gcmMessageIDKey]
{
debugPrint("Message ID: \(messageID)")
}
// Print full message.
debugPrint(userInfo)
completionHandler(UIBackgroundFetchResult.newData)
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error)
{
debugPrint("Unable to register for remote notifications: \(error.localizedDescription)")
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
{
debugPrint("didRegisterForRemoteNotificationsWithDeviceToken: DATA")
let token = String(format: "%#", deviceToken as CVarArg)
debugPrint("*** deviceToken: \(token)")
let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})
debugPrint("deviceTokenString: \(deviceTokenString)")
Messaging.messaging().apnsToken = deviceToken
// debugPrint("Firebase Token:",InstanceID.instanceID().token() as Any)
}
}
// [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) {
//Handle the notification ON APP
Messaging.messaging().appDidReceiveMessage(notification.request.content.userInfo)
completionHandler([.sound,.alert,.badge])
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: #escaping () -> Void) {
//Handle the notification ON BACKGROUND
Messaging.messaging().appDidReceiveMessage(response.notification.request.content.userInfo)
completionHandler()
}
}
// [END ios_10_message_handling]
extension AppDelegate : MessagingDelegate {
// [START refresh_token]
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
print("Firebase registration token: \(fcmToken)")
InstanceID.instanceID().instanceID
{
(result, error) in
if let error = error
{
debugPrint("Error fetching remote instange ID: \(error)")
}
else if let result = result
{
debugPrint("Remote instance ID token: \(result.token)")
}
}
let dataDict:[String: String] = ["token": fcmToken]
NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
// TODO: If necessary send token to application server.
// Note: This callback is fired at each app startup and whenever a new token is generated.
}
// [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) {
debugPrint("Received data message: \(remoteMessage.appData)")
}
// [END ios_10_data_message]
}
Podfile:
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
def shared_pods
pod 'Fabric'
pod 'Crashlytics'
pod 'Alamofire', '~> 4.7'
pod 'RealmSwift'
pod 'SwiftyJSON'
pod 'PKHUD', '~> 5.0'
pod 'Siren'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'Firebase/DynamicLinks'
pod 'Firebase/Crash'
end
target 'Sprite Kit Game' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Sprite Kit Game
shared_pods
end
target 'Sprite Kit GameTests' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for testing
shared_pods
end
target 'Sprite Kit GameUITests' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for testing
shared_pods
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# This works around a unit test issue introduced in Xcode 10.
# We only apply it to the Debug configuration to avoid bloating the app size
if config.name == "Debug" && defined?(target.product_type) && target.product_type == "com.apple.product-type.framework"
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = "YES"
end
end
end
end
no notifications are received neither by foreground nor background, any help, please?
The issue was resolved to update this part of the code handling the message/push notification from Firebase console
// [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
if let messageID = userInfo[gcmMessageIDKey] {
debugPrint("Message ID: \(messageID)")
}
debugPrint(userInfo)
//Handle the notification ON APP
Messaging.messaging().appDidReceiveMessage(userInfo)
completionHandler([.sound,.alert,.badge])
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: #escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
if let messageID = userInfo[gcmMessageIDKey] {
debugPrint("Message ID: \(messageID)")
}
//Handle the notification ON BACKGROUND
Messaging.messaging().appDidReceiveMessage(userInfo)
completionHandler()
}
}
// [END ios_10_message_handling]
the issue was tracked on GitHub
Make sure you updated iOS Deployment Target in the NotificationService settings
I want to implement older Firebase notification any link for older SDKs and old Pod version
I am using Xcode 7.3 and I want to implement firebase push notification but
due to latest pod I can't run project and comes error in FIRMessagingDelegate and FIRInstanceID I install both pod but method is not working.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
application.registerUserNotificationSettings(pushNotificationSettings)
application.registerForRemoteNotifications()
return true
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
print("DEVICE TOKEN = \(deviceToken)")
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
print(error)
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
print(userInfo)
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
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)
}
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()
}
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
}
Finding pod Version in change log and install pod
pod 'Firebase', '~> 3.10'
pod 'FirebaseMessaging', '~> 1.0’
and after install pod
letest pod dose't suppot userNotifications Framwork