Where to save app info to survive reinstallation after building? - xamarin

I currently use App.Current.Properties dictionary to save some basic data needed for the app to connect to a database.
Unfortunately, when building and reinstalling the app on the Android simulator (didn't tried on the iOS one), app data seems to be wiped, so every time I test the app I've to re-enter connection info.
How can I avoid that?

Does it work if you start the app without redeploying it? If you just click the app icon on the emulator. If it does not you have propbarly forgot to call the save method.
Application.Current.SavePropertiesAsync();

Related

Xamarin.Auth doesn't persist data after closing the app - ios

I have built an application through Xamarin.Forms, I am using xamarin.auth to save sensitive (login) data on each platform, Android app works correctly, I login to the app, save the data, close the app, re-open it and no need to login, the app goes directly to the home page, but in ios every time I open the app I need to login, and after that I close it and re-open it again I need to login again, I think there is something missed, I am debugging on a real iPhone 7 plus device, any help please?

Xamarin.Forms application properties not saved between sessions with Android

In my cross-platform app I save application properties in the following way:
Application.Current.Properties["myValue"] = "Test";
await Application.Current.SavePropertiesAsync();
I then retrieve them later like this:
string myVal = Application.Current.Properties["myValue"];
This works perfectly when using the Android emulator. I can close the emulator down, and when I restart it again, my app data is preserved.
However, when I deploy this app to a physical Android device, data preservation works as expected until I close the app and open it again. At this point I retrieve an empty value. It's as though the data is only saved to memory (and not to file).
Furthermore, the iOS version of the exact same app works faultlessly. When I open the app up, all previous values have been saved and I can retrieve them.
What am I doing wrong on the Android version? Is there an Android setting, permission, or option which I need to enable to have the values saved between app sessions when actually deployed to a phone?
I had a similar problem where only the debug version saved Properties. I think we're still waiting for the bug fix, and this is the workaround on Xamarin Forms bugzilla.
In short: go to .Droid project settings -> Android Options -> Linker
and enter/add "System.Runtime.Serialization" to Skip linking assemblies.
Wow! After lots of research, I have getting solution for same issue in mine. Problem is that, when i store List or DataTable in Application.Current.Properties then all properties are removed after reopen app but if i store List or DataTable as serialize, it working fine.
In VS you need to enable the option:
Preserve application data/cache on device between deploys
You can find this at Tools > Options > Xamarin > Android Settings.
I don't know if this has stopped in the latest updates of Xamarin Forms, the data is available until the application is running similar to session but persistent storage does not work.
The best api I think available for this is Akavache https://github.com/akavache/Akavache.
You can read this blog https://codemilltech.com/akavache-is-aka-awesome/.
Update
There is a bug filed in bugzilla:
https://bugzilla.xamarin.com/show_bug.cgi?id=26444
I don't remember exactly which part of this solved the issue, but when I followed the instructions to prepare the Android application for release from start to finish, the issue went away. The problem occurred when debug builds were used on an Android device.
https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_1_-_preparing_an_application_for_release/
The link details the suggested settings for the Android project when releasing to device. Following these instructions should solve the issue.

Xamarin Android losing keystore after each deploy in emulator

I'm discovering Xamarin Android with Visual Studio and I'm working with the keystore.
All my code is based on Xamarin's https://github.com/xamarin/Xamarin.Auth
When I deploy and use the keystore, everything is working fine. Data are persisted and I can save, delete and retrieve them without a problem.
I can turn off the emulator or kill the application, the keystore is still here with the data in it.
But if I modify the code and redeploy the application without stopping the emulator, my keystore is lost.
Any idea on where I should start digging to troubleshoot this problem. I don't have any exception.
Looks like you need to set the setting to Preserve application data/cache on device between deploys.
Check this answer for details:
SharedPreferences not saving values properly

Cloudkit error when querying public database from simulator

I'm working on an app where I recently decided to go with CloudKit and am now at the point where I need to implement the backend functionality. In a nutshell, this app will use a collectionview to display images retrieved from a CK database. Up until now, I just dumped some images in a folder on my desktop and retrieved/parsed the images from there to render the collectionview. I then used the CK dashboard to create some records and wrote an initialization method to try and retrieve them. I was getting various CKErrors, such as network failure, error completion without receiving a response from the server, could not send a valid signature, etc. I immediately assumed the issue was with my code since it was my first attempt with CloudKit. However, I ran the latest code on my device before posting on SO and it worked! I got a successful response with the number of records in the results array that I was expecting.
So now I know longer need help with fetching CKRecords like I initially thought. But how do I resolve this issue with the simulator? I saw some other post about making sure you're signed into iCloud on the simulator. I believe I am, but do not know how to check to be sure. Also, I'm running Yosemite and Xcode 6.1.
Any help is appreciated!
on the simulator go to the settings app. You can do that with menu hardware, home and then open the settings app, select iCloud and make sure that you are logged in.
To use your Apple ID on iCloud on the iPhone Simulator, make sure you turn off Two-way authentication. It should then work on the simulator.

Can you get a crash log from iTunes Connect when you build on an app you downloaded?

Can you get an iTunes Connect crash log when you download your app from the App Store and then build on that app using Xcode?
Let's say I have a released version, and I download it from the app store to test, then later on I want to make some changes to my code.
I don't delete the downloaded app, but I just build over it from Xcode. Then I add a lot of breakpoints during the initial launch to check. Suddenly, my app crashes because it isn't able to launch in time.
Will the crash be sent to iTunes Connect?
Also, it is possible for your app to fail launching when you have a lot of break points added and you try to step into things?
I'm using Xcode 4.6.
Once you run your app from Xcode, your app is no longer the same app. It is now your development app. If it crashes, nothing is sent to iTunes.
When you run your app through Xcode, the timeout is disabled. You could let it sit for a week and the OS will not kill it for taking too long to startup.
And I believe you mean "iTunes Connect" where ever you mention "iTunes".

Resources