5
votes

I create a new XF project using 4.0.4.4 XF. Nowhere can I find App.AppName. I'm trying to follow the tutorial at https://developer.xamarin.com/guides/xamarin-forms/web-services/authentication/oauth/ where it is definitely referenced in docs.

If I create a public property in PCL / App.cs with AppName it appears to work fine. Is this the right way?

Usage in the tutorial The following code example shows how an Account object is securely saved on the iOS platform:

AccountStore.Create ().Save (e.Account, App.AppName);

The following code example shows how an Account object is securely saved on the Android platform:

AccountStore.Create (Context).Save (e.Account, App.AppName);
2

2 Answers

7
votes

"App" in those examples is the subclass of Application:

public class App : Application

So whatever you named your solution/project the you created it will be the name of the Application subclass:

public class YourAppNameHere : Application

Then AppName that they are referring to is is a class-level variable defined in that class:

public static string AppName { get { return "TodoListApp"; } }

Checkout out the sample source @ https://github.com/xamarin/xamarin-forms-samples/blob/master/WebServices/TodoAWSAuth/TodoAWS/TodoAWS-SimpleDB.cs

6
votes

AppName is just a string that AccountStore uses to identity your app. It may be that at one time the default Forms template included an AppName property and doesn't anymore, and the documentation is outdated. In any case, simply using a hardcoded value, or creating your own AppName property, should be fine.