The iPhone app closes immediately when I open the map [closed] - ios

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 10 months ago.
This post was edited and submitted for review 10 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance
full description

You need to add the google map API key on ios/Runner/AppDelegate.swift file
import UIKit
import Flutter
import GoogleMaps
#UIApplicationMain
#objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GMSServices.provideAPIKey("GOOGLE_API_KEY")
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}

Related

App crashing [FIRApp appWasConfiguredTwice:usingOptions:]

iOS Extension - Fatal Exception: com.firebase.core Default app has already been configured.
enter image description here
From the message it is clear that FIRApp's configure function is called twice by your app. It is supposed to call once. The best place to call it, is in the func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool in your AppDelegate.
In order to identify from where it is being called you can use 2 approaches.
Press CMD + Shift + F and search for configure keyword and identify from the results.
Add a symbolic break point and app will pause when configure function get called. See the screenshots below:

BGAppRefreshTask in the BackgroundTasks

I have this code that show a message "Msg Background" when the application is in Background. What I need is that as long as the application continues in the background show that message every 2 minutes (just an example of time). So far the code I have shows the message only once, apparently this sentence is not working properly.
UIApplication.shared.setMinimumBackgroundFetchInterval (UIApplication.backgroundFetchIntervalMinimum)
I also have this warning: 'setMinimumBackgroundFetchInterval' was deprecated in iOS 13.0: Use a BGAppRefreshTask in the BackgroundTasks framework instead
I am using swift 5 and Xcode 11
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
GMSServices.provideAPIKey("AIzaSyBSpAt5zqvbh73FmG_Kb6xpiFMkWRmHppg")
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalMinimum)
return true
}
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult) -> Void) {
print("Msg Background")
}
}
As Paulw11 said, it's not called in fixed interval. The OS controls when it is going to be executed. We cannot expect the specific time because of it.
You probably know this, but I'm going to add this bit just in case, setMinimumBackgroundFetchInterval has deprecated on iOS 13 and later. You might want to consider to use BackgroundTasks Framework instead.
but if you want to test performFetchWithCompletionHandler, you can use XCode Navigation Bar > Debug > perform Background Fetch.
screenshot of XCode navigation bar to find option
I hope it can help!

Firebase configuration not working

the Firebase configuration is not working even though it is called in the app delegate method
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure();
confic(application: application);
return true
}
I did not had this problem before where my classes were initialised as singletons those particular classes are dependent on Firebase however I decided to instantiate them individually in each view controller instead of using singletons however now I'm getting this issue can anyone help?.
I also tried removing any calls to Firebase from the Appdelegate class and just have FirebaseApp.configure(); included in the delegate however this did not help either.
theconfic(application: application); method contains all my Firebase related calls such as checking if the user has logged in etc.
I moved in here as in previous post I read this may help however it made no difference still getting the same error
Error message
2018-05-16 16:23:42.201080+0100 Jagdschule Gut Grambow[1983:376501] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The default FIRApp instance must be configured before the default FIRAuthinstance can be initialized. One way to ensure that is to call [FIRApp configure]; (FirebaseApp.configure() in Swift) in the App Delegate's application:didFinishLaunchingWithOptions: (application(_:didFinishLaunchingWithOptions:) in Swift).'
* First throw call stack:
(0x1841cad8c 0x1833845ec 0x1841cac6c 0x1021d8244 0x10213b510 0x1021321e8 0x1021209cc 0x102120b5c 0x18e40dedc 0x18e56f628 0x18e56f7a0 0x18e56f360 0x18e23d2c8 0x18e26b4d0 0x102097890 0x102097940 0x18e40dedc 0x18e56f628 0x18e56f360 0x18e23cf24 0x10216b674 0x10216b728 0x18e40dedc 0x18e56f628 0x18e56f360 0x18e40db84 0x18e40e31c 0x18e56f628 0x18e56f7a0 0x18e56f360 0x18e40ced4 0x18e719d88 0x18e17bfd8 0x18dd99254 0x18dd67550 0x18e397a0c 0x18dd66e4c 0x18dd66ce8 0x18dd65b78 0x18e9fb72c 0x18dd65268 0x18e7e09b8 0x18e92eae8 0x18dd64c88 0x18dd64624 0x18dd6165c 0x18dd613ac 0x1869c8470 0x1869d0d6c 0x103aa9220 0x103ab5850 0x1869fc878 0x1869fc51c 0x1869fcab8 0x184173404 0x184172c2c 0x18417079c 0x184090da8 0x186073020 0x18e07178c 0x102130644 0x183b21fc0)
2018-05-16 16:23:42.201344+0100 Jagdschule Gut Grambow[1983:376766] 5.0.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add [FIRApp configure]; (FirebaseApp.configure() in Swift) to your application initialization. Read more:
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

persistenceEnabled works in simulator, but raise a NSInternalInconsistencyException on device

I've enable Firebase's disk persistence in my app by setting persistenceEnable to true
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
FIRDatabase.database().persistenceEnabled = true
return true
}
When I run the app in xcode's iPhone simulator everything work as expected but when I run the app on the device I get an NSInternalInconsistencyException.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unrecognized database version: '
*** First throw call stack:
(0x18e68d1b8 0x18d0c455c 0x18e68d100 0x10014323c 0x100143124 0x100154434 0x100de9258 0x100de9218 0x100df6aec 0x100decce0 0x100df7088 0x100df8e2c 0x100df8b78 0x18d71f2a0 0x18d71ed8c)
libc++abi.dylib: terminating with uncaught exception of type NSException
I don't really know what's happening. It looks like the exception is thrown when attaching an 'observe' listener
let ref = FIRDatabase.database().reference()
ref.child("usersEvents").child(userID!).observe(.value, with: { (snapshot) in
...
If I comment the persistenceEnabled = true
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
//FIRDatabase.database().persistenceEnabled = true
return true
}
The app works on my device but of course I loose the offline capabilities.
I've also tried to move the FIRDatabase.database().persistenceEnabled = true but each time I use it the app crashed when executing on the iPhone.
Thanks and regards.
TLDR;
I remove the app from my device and let xCode install a fresh copy of it and that solved the issue.
Full comment :
After some trying to reproduce the issue in an other project for several hours without success I found the solution.
The error message is not 100% clear but gives a good clue Unrecognized database version:
As the app was only crashing on my device when persistenceEnabled was set to true I figured out the issue must have been related to the local database cache.
I remove the app from my device and let xCode install a fresh copy of it and that solved the issue.
Somehow the local Firebase cache must have been corrupted and each time Firebase's sdk tried to access it my app crashed.
I hope this may help someone facing the same issue some days.

Swift- application didFinishLaunchingWithOptions method: [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
What does it mean to put something in my application didFinishLaunchingWithOptions method:. And how do i do it in swift?
There is a boiler plate method provided in your iOS project's AppDelegate file defined as
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch. Here you can out the code you want.
return true
}
If you want to handle cases such as if app is opened by a URL or by remote notification then you might want to put your code before return.
If the app can handle the url then keep the return value true otherwise false. In case of push notification, the return value would anyway be ignored.
Hope this would help.
This function gets invoked right before your app is fully loaded. If you're familiar with jQuery, it's sort of like $(document).ready(function() {}) Below is a link to documentation from Apple on how to implement this function:
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/index.html?hl=ar#//apple_ref/occ/intfm/UIApplicationDelegate/application:didFinishLaunchingWithOptions:
application:didFinishLaunchingWithOptions: is part of the UIApplicationDelegate protocol, which is responsible with handling different changes over your application state. You can find out more about this method and about the app delegate protocol in the Apple documentation from here. I strongly recommend reading it before moving forward.
You should get the below code automatically generated by Xcode if you create a brand new Swift iOS project:
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
// ...
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
You can place the code you need into that method, or add the method to your UIApplicationDelegate if it's not already there.

Resources