iOS: GooglePlaces API error - ios

I am getting this error when trying to use the sample code from Google Places getting started Link
Error: Current Place error: The operation couldn’t be completed. An internal error occurred in the Places API library.
I am calling this function on viewDidLoad. I also created a IBAction with this code to make sure it wasn't a timing issue. I got the same error this way as well.
placesClient.currentPlace { (placeLikelihoods, error) in
guard error == nil else {
print("Current Place error: \(error!.localizedDescription)")
return
}
if let placeLikelihoods = placeLikelihoods {
for likelihood in placeLikelihoods.likelihoods {
let place = likelihood.place
print(place.name)
}
}
}
I have created a new project in Firebase, which created a new project in Google Dev Console. I created new API Key, Enabled Google Maps and Google Places API. I added CoreLocation framework, my pods are up to date. I should not be hitting any limits as it is just me learning. I have the Location When In Use set up i the Plist - user gets the dialog on fresh install. I accepted it. I added location manager code from here to make sure I am getting the location. I signed up for Apple developer to get the app on my device just in case the location wasn't staying on the simulator. I have a feeling this is something stupid. Please let me know any ideas to get passed this. Thanks!

Related

configure firebase with options is crashing in Xcode 11 and Firebase 6.19

I'm trying to register a second firebase application in my app. The first one is correctly registered inside didFinishWithLaunchingWithOptions method (by default is using the GoogleService-Info.plist)
FirebaseApp.configure()
Then I need to retrieve a new googleAppId from a server and configure a new application using this new googleAppId and using my iOSID of curse. I am doing all this registration inside AppDelegate. I'm registering this way:
let options = FirebaseOptions(googleAppID: String(format: "1:%a:ios:%a", googleID, iOSID), gcmSenderID: googleID)
//Deleting the first app in order to register the second
let app = FirebaseApp.app()
app?.delete { _ in }
FirebaseApp.configure(options: options)
It was working well until I update my firebase version from 6.2 to 6.19, now the app is crashing in FirebaseApp.configure(options: options)
The log says:
Terminating app due to uncaught exception 'com.firebase.installations', reason
'[Firebase/Installations][I-FIS008000] Could not confiure Firebase Installations die to invalid
Firebase options. The following parameters are nil or empty: `FirebaseOptions.APIKEY`. If you
use GoogleServices-Info.plist please download the most recent version from the Firebase Console.
If you configure Firebase in code, please make sure you specify all required paramaters.
Is worth mencioning that a new Framework was added to Analytics in Firebase version 6.15 so I had to added it in order to make my app compile again.
I also tried to add a new parameter inside the FirebaseOptions but is still asking for the same parameters, it is not expecting an APIKEY which i don't know where to get it
The message comes from here as far as I can see. The check done there shows that these three values must always be specified:
if (appName.length < 1) {
[missingFields addObject:#"`FirebaseApp.name`"];
}
if (appOptions.APIKey.length < 1) {
[missingFields addObject:#"`FirebaseOptions.APIKey`"];
}
if (appOptions.googleAppID.length < 1) {
[missingFields addObject:#"`FirebaseOptions.googleAppID`"];
}
From the error message and your code it looks like you're not specifying the APIKEY in your FirebaseOptions, which is required according to the SDK.

loadAppContextDataFromInbox error loading in application context from inbox NSFileReadNoPermissionError -> EACCES

I have been developing an app the works with the apple watch's workouts and an iPhone. The app is written in swift and communication has been working properly for weeks while I add features. I am suddenly getting the following error code when I try to run my app on my iPhone.
[WCFileStorage loadAppContextDataFromInbox] error loading in application context from inbox NSFileReadNoPermissionError -> EACCES
This error is being generated on a program that was working fine using the same code. I believe the error is coming from the following line of code:
WCSession.default.updateApplicationContext(dictionary)
in the func shown below.
func sendAppStateToWatch(appState : String?) {
if WCSession.isSupported() {
if let appStatus = appState {
do {
let dictionary = ["iOSAppState" : appStatus]
try WCSession.default.updateApplicationContext(dictionary)
} catch {
print("sendActiveTimeToPhone() ERROR: \(error)")
}
}
}
}
This function has been working without problem for at least a month. Suddenly, I am getting the error shown above. I have rebooted the watch, phone and Xcode without effect. I suspect the error comes from some privacy setting on the phone or watch that flipped, but looking around I cannot find the problem. Any help is appreciated.

initiaize object of AGSGeodatabase with file path is returning "File not found

I want to post this question on esri community, but I was not able to login there.
I created the offline geo database and showing the layers from it to the map.
My issue is when i download the geoDatabse and show the data from it is working fine for the first time.
But when I restart the app and create the AGSGeodatabase object from path then the "self.generatedGeodatabase.load" function gives error
Error Domain=com.esri.arcgis.runtime.error Code=14 "File not found" UserInfo={NSLocalizedFailureReason=, NSLocalizedDescription=File not found, Additional Message=}
my created url is :-
file:///var/mobile/Containers/Data/Application/60CF7AE1-2DE1-4FA0-805A-6140D4829E89/Documents/GeoDatabase/2018-05-134T18:29:01+0530.geodatabase
and I'm creating object is like this :-
if let geoDatabasePath = URL(string: SettingsManager.geoDatabasePath) {
self.generatedGeodatabase = AGSGeodatabase(fileURL: geoDatabasePath)
self.displayLayersFromGeodatabase()
}
and error is coming when this function runs:-
self.generatedGeodatabase.load(completion: { [weak self] (error:Error?) -> Void in
if let error = error {
print(error)
}
})
Previously I was just saving the path of the geoDatabse to preference (when creating the geoDatabse) and app is not detecting the geoDatabse at that location when I restart the app even the file is there.
The solution to this problem I find is to detect the geoDatabse path at runtime and create path using FileManager. Then it works.

ContentExtensionsDomain error 1

I am trying to use "reloadContentBlockerWithIdentifier" function of SFContentBlockerManager as follows:
[SFContentBlockerManager reloadContentBlockerWithIdentifier:#"appid.extensionid"
completionHandler: ^ (NSError *error) {
NSLog("%#", error.localizedDescription)
}
However, it only returns error message that said as follows:
The operation couldn’t be completed. (ContentExtensionsDomain error 1.)
I set both APP IDs (appid and appid.appextensionid) in "Certificates, Identifiers & Profiles" in developer.apple.com. Also, I made two "target"s for each -- ios app and ios app extension. I also checked open source implementations in Github which are roughly the same as mine, and App Extension manual several times, but it seems hard to find the relevant page for this problem. The most critical problem is: I couldn't find any offcial documents describing this message.
I'd appreciate if you let me know what is the problem.
Looking at the safari services generated swift interface, I could find the following enum for error codes:
public enum SFContentBlockerErrorCode : Int {
case NoExtensionFound
case NoAttachmentFound
case LoadingInterrupted
}
So in your case it's probably the NoAttachmentFound error. Which can be caused by failure to initialise an item provider with given data from a json file.

Google Places Callback not being called in Swift iOS

I am using the GoogleMaps SDK (maps & places). For some reason the following callback is not being called. I have put loggers in there but nothing happens.
var placesClient : GMSPlacesClient?
...
func run(){
self.placesClient?.currentPlaceWithCallback({ (list: GMSPlaceLikelihoodList?, error: NSError?) -> Void in
if let error = error {
println("error: \(error.description)")
return
}
if let list = list {
self.renderList(list)
}
})
}
For some reason the block in currentPlaceWithCallback does not get called. Yesterday it happened because my API had a wrong bundle identifier, after changing which it started working. But today it stopped.
Any idea why this would happen ? Also, are we exposed to any API logs by Google ?
I was getting the same issue on my iPhone 6 device AND iPhone 6 simulator.
The fix was to add the NSLocationWhenInUseUsageDescription permission in Info.plist! But, it worked only on my iPhone 6 device, NOT the simulator.
As mentioned in the Google Place Guide:
(https://developers.google.com/places/ios-api/start)
Please note, as this sample requires access to the location of the device to get the current location, you will need to set the NSLocationWhenInUseUsageDescription key with appropriate explanatory text in your project's Info.plist file. For more details, see the guide to getting current place.
Now, the way I got it working on the iPhone simulator was by changing my location on the Simulator: Debug -> Location. That is, it was set to 'Apple' by default, I just changed it to Bicycle Ride.
It worked for me, may not for all.

Resources