HERE API license key for iOS starter - here-api

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.

Related

Setting up Firebase with SwiftUI some questions

So I'm watching some videos about how to setup Firebase with SwiftUI but none of them really seem to be the most recent?
The latest video I found just does two steps, importing Firebase, then making an init in my app struct that calls FirebaseApp.configure() like this:
import SwiftUI
import Firebase
#main
struct FirestoreDemoApp: App {
init() {
FirebaseApp.configure()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
But Firebase has a bunch of code and tells me to set it up like this:
import SwiftUI
import FirebaseCore
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FirebaseApp.configure()
return true
}
}
#main
struct YourApp: App {
// register app delegate for Firebase setup
#UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
NavigationView {
ContentView()
}
}
}
}
But both of those still seem to work? Could someone maybe explain what exactly the second one is with all this AppDelegate and what's the point of it? Why is the first option which is much shorter also working just fine?
Firebaser here - actually, I am the person who made the change to our onboarding flow that recommends using the #UIAppDelegateAdaptor approach.
TL;DR: Both approaches work fine, but the #UIAppDelegateAdaptor approach covers more use cases.
Initialising Firebase in your app's initialiser works for most of Firebase's APIs, such as Firestore, RTDB, (most of) Authentication, etc. However, some APIs, such as FCM or Phone Number Authentication need an App Delegate.
Since we didn't want to make the onboarding flow more complicated than necessary (e.g. by asking people if they are planning to use FCM or Phone Auth, or making them read a lengthy blog post), we decided to take the safe route and recommend the slightly more complicated-looking approach that covers all use cases.
For an even more detailed explanation, check out my blog post, Firebase and the new SwiftUI 2 Application Life Cycle.

Onesignal "Apns Delegate Never Fired" while using Firebase Auth with and without swizzling

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

Firebase Phone Auth not receiving silent notification on SwiftUI

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)
})
}
}
}

No such module ‘FirebaseUI’

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.

How to implement Push notification in xcode 7.3

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

Resources