c# - MVVM Xamarin app -
i building app xamarin, using pcl project, have core functionality there, platform specific implementations in different projects. using mvvm structure, xamarin have complicated things. using xamarin.auth, allows oauth2 logins, available on .ios , .droid projects.
so have "log in with?" prompt on view in core project. go platform specific project calls custom renderer (model shown here).
here code in renderer, needs "customised" based on authenticator selected user.
var auth = new oauth2authenticator ( clientid: "xxx", // oauth2 client id (for fb called app-id) scope: "", // scopes particular api you're accessing, delimited "+" symbols authorizeurl: new uri ("https://m.facebook.com/dialog/oauth/"), // auth url service (i.e fb, twitter) redirecturl: new uri ("http://www.facebook.com/connect/login_success.html")); // redirect url service what correct way of doing this? use public variables communicate this, pass details through? etc. simplest solution?
you must create dependency class,that's correct way.
don't use renderer, visual work if possible in core , let specific of oauth class.
to create interface exposing methods need use , in specific projects create class implementing interface , decorated dependency attribute.
when need use ask dependencyservice instance of interface , retrieve correct class specific projects.
here documentation dependencyservice: https://developer.xamarin.com/guides/xamarin-forms/dependency-service/
Comments
Post a Comment