Firebase Connection Killed - swift

I have integrated Firebase into my iOS project. I have been using Firebase for years across many projects. This specifically is using the Firestore. I can authenticate fine and write to the database. However, after the write is complete, even though it's successful, I receive the following message:
Firebase Database connection was forcefully killed by the server. Will not attempt reconnect. Reason: Firebase error. Please ensure that you spelled the name of your Firebase correctly
The bundleID was copied and pasted directly from the app to the Firebase setup. I even deleted the app from Firebase and created it again. I have downloaded the GoogleService-Info.plist and I checked that the bundle there matches the bundle of the app. I can see nothing wrong here and again functionality is working fine.
The only instance I saw of this message browsing around was with a non-US based developer and it was suggested that additional config was required. However, that is not the situation for me. What else might cause this error to be generated?

The error message seems to point towards Realtime Database, despite your interest in Cloud Firestore.
I recommend:
Making sure you're using the latest SDK. Old SDK versions (before mid 2020) might require the Realtime Database URL to be present in the plist file, which isn't always the case anymore.
If step 1 doesn't solve the problem, you can:
Force the creation of a Realtime Database instance in the Firebase console.
Download the updated plist file and add it to your project.
If you end up with the second solution, can you comment with the SDK version you're using, so that I can check for issues in that?

Related

Firebase is uploading & fetching data on another app server

I was working on 2 projects at a time. Everything was working fine but when I uploaded my data from my app to the firestore, it was not found in the firestore. After checking it I found that it is uploading my data to my another firebase app database. Please help me resolving the issue I cannot find the error. It was working fine before, now both the apps are crashing.
My best guess is that you switched up the files that contain the information on how to connect to Firebase between these projects.
If you recently created these apps, that data is likely in a firebase_options.dart file that was created by the flutterfire CLI command.
But otherwise the information may also be stored in a google-services.json file for Android, and a GoogleService-Info.plist file for iOS.
Whichever of these it is, you'll want to check the data in these files and update them to refer to the correct Firebase project for each app.

Flutter app losing local data when user closes the app

My app uses both shared_preferences and writing to a local json file (getting path using path_provider) for the data that it uses. I recently started testing it (starting 1/1/22) with a larger group and some people are having an issue where the data is lost when they close the app and reopen it. We're testing on both Android and iOS. The first user to have the issue was on iOS and has had it from the beginning. All the other users ran into the problem a couple of days ago (1/12/22) and is a mix of mostly iOS and 1 Android user.
The data persists while the app is running since it's consistent while the user navigates around. I haven't been able to replicate the problem myself and I haven't been able to find out what the issue in my research. Any thoughts of what may be going on?
I found a similar question that mentioned that path_provider provided different paths for storage, but that doesn't seem to be my issue here since the first piece of data that gets called is the shared_preferences data and that is also getting lost.
I did some troubleshooting and we figured out that the devices (mostly iOS) were deleting the data point from shared_preferences. I migrated that point of data to a json file and the issue disappeared. It does say in the documentation not to use shared_preferences for any critical piece of data and now I see why. It worked initially, but had issues later for a lot of people, so I'm probably not going to use it in the future.

PhoneGap based App does not work after After App update in iOS5.1

I have a PhoneGap based iOS app which uses SQLite DB for offline storage. The app is not working after an app update in iOS 5.1. The same app is working fine in versions below 5.1.
I explored few things and my analysis is
When we install a app iOS creates a separate sandbox for that and all the data related to that app goes in to that.
in iOS5.1 when we update an app new sandbox is created and the contents from old sandbox is moved here.
For WebSQL i.e SQLite for PhoneGap in iOS 5.1 the DB is stored under caches folder(volatile storage). But in previous version of iOS the SQLite DB was stored under Documents folder in Sandbox which is persistent storage.
The real problem is there is a file called ".preferences" in caches/preferences that has the path of websql DB. when i do an app update the sandbox path changes but in this file the previous sandbox is path is still available due to this the app is not working as the previous path is already deleted from device.
Is this an Apple issue or can it be resolved by a developer?
I have fixed the issue by
The path referred by iOS to find WEB DB(SQLite) and Local storage is stored in NSUserDefaults.
So when i launch the app every time i check the path information and make sure it matches new sandbox path if not i set the value for that Key and now the app works fine.
NSUserDefault Key referred to SQLite path is WebDatabaseDirectory.
If Apple releases a fix for this issue in their next release, this code is not required.
Try to use cordova-1.6.0 or above this.
When I changed to cordova-1.6.0 , my problem is fixed.

Phonegap (1.4.1) Storage not working anymore with iOS 5.1

I developed an App for Android and iOS using Phonegap. Both Apps are already running successfully and available on the stores. Now I added some changes for an Update. If I have data stored (using the SQLite database) in the previous version and updating to the new one, the Storage Api on IOs 5.1 is not working anymore.
If I call
var db = window.openDatabase("mydb", "1.0", "", 5000000);
nothing happens.
It's working fine for Android, it's also working if I do a new install or if I do not have data already stored in the database from the previous version of my app. I'm using other Phonegap functions like Notification or localStorage, which are working perfectly fine.
Any help would be much appreciated, since I'm really running out of ideas :)
There is a fix for both issues with Webkit storage and iOS 5.1
Storage moved from /Webkit to /Cache
Storage is not adjusted to updated folder structure on an App update under iOS 5.1 (WebKit Bug)
https://issues.apache.org/jira/browse/CB-330
This solution seems to be more safe than just changing the location of Webkit data calling a private API. While the App is running the Webkit storage locations are used. On resuming or terminating all data is backuped to the documents folder. Timestamps ensure that ab old backup cannot overwrite newer storage data (if the app crashes...).
The best: Users that are on an older iOS Version using an App with that fix in it, will not suffer damage lost in case of any iOS updates. Thats why one should not wait...
It's strange, it should be working... By the way, in iOS5.1, WebSQL is considered tempory data that can be deleted at any time...
It's possible to change the location of WebKit data calling a private API. You should be able to set the location to a secure folder like Documents. I did not test this solution yet, but look at this post :http://stackoverflow.com/questions/4527905/how-do-i-enable-local-storage-in-my-webkit-based-application
I think the safer way is to use SQLite (same as WebSQL) with a phonegap plugin. That plugin save the database in the Document folder, that mean that the DB is not deleted and is saved by iCloud.
Here is the Native SQLite phonegap plugin : https://github.com/davibe/Phonegap-SQLitePlugin
Regarding this plugin, there are some differences between the WebSQL API, here is an adaptor:
https://gist.github.com/2009518
You should also migrate the old WebSQL db file (stored in Library/WebKit or Caches directory) to the Document folder. Here is a code to do that :
https://gist.github.com/2009491
There is also a fix implemented in the latest version of Cordova : https://issues.apache.org/jira/browse/CB-330 (it makes a backup of the DB files in the Document folder)
And if the data are important, you should save it to a server. I wrote a small lib to synchronize the SQlite DB to a server :
https://github.com/orbitaloop/WebSqlSync
There has been a Jira issue created on this: localStorage / SQLDatabase Error after App update

How to transfer application into device when testing inapp purchases

I found this information on a blog which talks about invalid product ids.
http://troybrant.net/blog/2010/01/invalid-product-ids/
I tried everything suggested in the
Apple forums and here, and still
couldn’t get it to work. Found the
solution – your app needs to be
transferred by Xcode for the sandbox
to be enabled.
Obvious, right? Well, if you are
working with an update to an existing
account, the device will still treat
it as an App Store-installed app.
Delete it, then transfer it again. It should work now :)
i am also getting invalid product ids.i am not able to get clear in the above said point...
i am not able to understand what i need to do when transferring the application into device...
Kindly guide me out and thanks for your help
That point just means that you need to run the app from Xcode in order for the sandbox to be available. (Build and Run)
Invalid product ids are a major pain to debug. If you're sure you've gotten everything on that checklist, then you just need to wait. Then only other problem that I've seen is that you might need to remove the app from the device and redeploy in order to get good products back from the store.
I had trouble getting the app store to recognize my sandbox test account. I had to log out wit iTunes, sync, then log in again with iTunes. Just using the device itself to log in/out didn't help.