How to Store user login credential in Xamarin.Form - xamarin.forms

I want to store the username and password of users locally. i have searched a lot can't find a working solution for Xamarin.forms.I have seen this official site that recommend to use Xamarin.Auth to store in keychain but the tutorial in on platforms specific which i dont know how to convert to Xamarin.Forms.
A little bit help on how to make this to work in Xamarin.Form is very much appreciate.

I have been using the SecureStorage plugin which saves these kinds of settings in the platforms secure storage from the shared code.
There are a couple of things good to know.
iOS
On the Simulator you could run into an issue where values do not get saved. To overcome this open the Entitlements.plist file and make sure that "Enable Keychain Access Groups" is checked. Also ensure that in Project->Options->iOS Bundle Signing, the Entitlements.plist is selected in Custom Entitlements for iPhoneSimulator platform.
Android
You have to set a password when initialising, like this:
SecureStorageImplementation.StoragePassword = "Your Password";
This will be used to encrypt te settings. Make sure you keep it secret and do not change it.
Windows
Same thing as Android, but now call WinSecureStorageBase.StoragePassword = "Your password";
If you have done this, you can now save any setting your like with:
CrossSecureStorage.Current.SetValue(“SessionToken”, “1234567890”);
Which can then be retrieved like this:
var sessionToken = CrossSecureStorage.Current.GetValue (“SessionToken”);
There are some more calls to delete a key and see if a key is present. Don't forget to install the NuGet package on both your shared code as well as your platform projects.

You can check on this link for how to use Xamarin.Auth in Xamarin.Forms.
One more option i would consider is using Akavache which can be used to store the data with same level of security & how to integrate it in Xamarin.Forms check on this link

Related

Send data from Share Extension to Xamatin.Forms app

I work on Share Extension. And it only has a sample project (following link) and a general extension documentation.
Basic project:
Extension documentation:
When I click share with my app on iphone (for example on photos), I want to send this file to my app and upload it remote server. But I couldn't find anyway to send object from share extension. I looked up and probably I need to use "NSUserDefaults" and I tried to use it that:
I did necessary settings (creating group id, app id etc) on my apple developer account.
I did necessary settings on my project Entitlements.plist
I try to send on ShareViewController - DidSelectPost method in the my project's share extension as below:
var default = new NSUserDefaults ("group.com.myapp.AppName", NSUserDefaultsType.SuiteName);
default.SetString ("Test content", "TestKey");
default.Synchronize ();
4)I try to receive string data on my main project's AppDelegate as below:
var default = new NSUserDefaults ("group.com.myapp.AppName", NSUserDefaultsType.SuiteName);
var key = default.StringForKey ("TestKey");
string value = key;
But I couldn't do it. And I saw someone did this with OpenUrl function. I tried this and this didn't work.
I started mobile programming with Xamarin forms and I don't know enough native iOS programming (I only learn with Xamarin). I think share extension has insufficient documentation.

how get key/value from nsuserdefaults .plist configuration file Xamarin forms

I am working as a Xamarin forms iOS enterprise app.
We pushed config.plist (Some key-value pair) file to a real device using Mobileiron/airwatch MDM/EMM(Services). Then we deploy the Apps on iPads using MobileIron. When the app starts, the app gets Url/ credentials from config.plist that pushed by MDM.
after googling I found config.plist stored in device which in NSUserDefaults​
But I am don't know is the .plist stored in NSUserDefaults with apps bundle id or something else.
Please anybody has the same issue before writing to me how I have to implements or getting value from .plist
I think you will find the details from your question on page 69-70 of Apple's MDM-Protocol-Reference. The MDM server deploys these settings using a dictionary that contains an array of bundle ids, with the settings for each app within their key. Because of how sandboxing works, your app just has to retrieve the com.apple.configuration.managed key to get its settings.
A great resource is https://www.appconfig.org/ios/

Will I have problems if I publish an app with a packagename different of bundle id?

Recently I had to change the package name of my android project because I had to disable an old app to change some pieces of information and some of the UI of it. But the business logic are pretty the same. So I wonder, can I use the same solution with a different package name for Android (for create another app in google play with the same name but different package name) and then keep the bundle id the same for iOS to not have to recreate another one in the app store? Will I have problems with it?
Thanks very much.
In my knowledge, there should not be any issues if you make sure about the following pointers:
Everything that was registered on the old bundle id is now registered for the new one and replaced with the new one all over your project. eg: if you have a firebase product used then you replace the old googleservices.json with the new one.
The old app that you have on the store is removed(To avoid confusion for users)
You can use the same key to sign the key but you cannot use the same App that you added on store earlier.
Make sure you do not have any dependency of any sort on the old bundle id.
Note: Your old app will not be replaced by this new one even though they would have the same name as the bundle id is the unique identifier for this.
There should not be any problems if you use the same bundle id for the new iOS app as you had earlier but usually, both apps have the same bundle just to keep it standard. But you can always opt. not to.
Goodluck feel free to get back if you have any more queries

Firefox webapp file input

I'm developing a webapp for firefox aurora (android). And i have an file input.
But when users click on the input they can't choose files from sdcard or filesystem only pictures, music or videos.
I search at MOZILLA DEVELOPER NETWORK, but couldn't find anything helpful.
In my manifest.webbapp i have device-storage permission:
"permissions": {
"device-storage:sdcard":{ "access": "readonly" }
},
I assume you are currently simply using the markup ?
The device-storage:sdcard is for a very different set of use cases really. And we don't have that implemented on Firefox for Android yet.
The list of applications being shown is just the set of applications that we're getting from the Android Intents system. I would imagine that if the user has some sort of filebrowser app installed it might respond to that intent and it'd pop up there.
But of course that's not something you can rely on in your app.
I'm honestly somewhat surprised that there's no default applications on android that provide that functionality, but I guess that's how it is. Or does someone know of a way to also get a filepicker intent that we can hook up to?
Medium term you will be able to use the DeviceStorage API. This will give you direct JS access to the sdcard which will allow you to build your own UI for choosing a file from the SD card. But that extra power comes with quite a few downsides. It's a privileged API which means that you'll have to write the app as a packaged app and you have to use CSP. And you'll have to go through the Firefox marketplace review process (all privileged apps have to go through code review).
So it's a pretty distant second choice.
Other than that there aren't any solutions. The best would of course be if there was a way we could plopp up an Android file picker, but I'm not sure if that's doable. And it's definitely not implemented yet.
According to the source code, this permission is only granted to apps that are packaged and privileged, the latter also means the app has to be signed by the Marketplace.
You can find more about packaged apps and privileged app types here:
https://developer.mozilla.org/en-US/docs/Apps/Packaged_apps
Just install an Android file manager app (https://play.google.com/store/search?q=file+manager&c=apps) and you will be able to select files from the SD card. There is no need for specific rights because this is handled automatically by the standard file input.
Accessing the SD Card can only be achieved through a privileged or certified app. Currently to my knowledge, there is no integration the system menus as you are hoping would be the case. Personally, I'm hoping that this will change.
API Documentation: https://developer.mozilla.org/en-US/docs/WebAPI/Device_Storage
You could create your own menu that mimics the the system one; in this way the user gets a seamless experience and they don't know the difference. It would require a little boilerplate though it's not insurmountable levels of boilerplate.
A quick snippet for browsing/enumerating all photos on the the SDCard:
var storage = navigator.getDeviceStorage("sdcard");
sdcard.browse = function () {
var pics = navigator.getDeviceStorage('pictures');
// Let's browse all the images available
var cursor = pics.enumerate();
cursor.onsuccess = function () {
var file = this.result;
alert("File found: " + file.name);
// Once we found a file we check if there are other results
if (!this.done) {
// Then we move to the next result, which call the cursor
// success with the next file as result.
this.continue();
}
}
cursor.onerror = function () {
alert("No files found: " + this.error);
}
};
If you would like some more details for reading, writing, and caulating available storage, I'm currently working on a little wrapper library in my spare time to work with the SDCard more easily (and handle some callbacks to integrate better with other code) in my spare time and can probably help you out.

Does Services module still need a key

I'm reading a book that suggests that you try to configure the Services module, you should see 3 tabs: Browse, Settings, and Keys. I'm working with the latest release and all I see is Browse and Settings. Anyone knows what happened to the Keys tab? Has the module logic changed?
If you enable Key Authentication within Services, Keys will present itself.

Resources