android - Auth0 with Xamarin PCL Dependency Service NullReferenceException -


i'm trying use dependencyservice auth0 component , stuck system.nullreferenceexception: object reference not set instance of object error.

following code in android project :

namespace loginpattern.android {  [assembly: xamarin.forms.dependency (typeof(loginpattern.android.auth0widgetlogin))] public class auth0widgetlogin : formsapplicationactivity, loginpattern.iauth0widgetlogin {      private auth0client auth0 = new auth0client (                                     "xxx.auth0.com",                                     "xxxxxxxxxxxxxx");      public auth0widgetlogin ()     {     }      public async task<loginpattern.user> loginuseauth0embeddedwidget()     {         auth0user usr = null;           try {             usr = await this.auth0.loginasync(forms.context);         } catch (exception ex) {             throw ex;         }          loginpattern.user userobj = new user(usr.auth0accesstoken);          return userobj;      } } } 

this in shared library :

namespace loginpattern {     public interface iauth0widgetlogin     {         task<user> loginuseauth0embeddedwidget();     }      public class user     {         public user(             string accesstoken)         {             accesstoken = accesstoken;         }          public string accesstoken {get; private set;}         public string scope {get; private set;}     } } 

am getting error here when calling dependency service:

public async void login ()     {         loginpattern.user usr = null;         usr = await dependencyservice.get<iauth0widgetlogin>().loginuseauth0embeddedwidget();         app.current.properties["isloggedin"] = true;     } 

place attribute above namespace declaration:

    [assembly: xamarin.forms.dependency (typeof(loginpattern.android.auth0widgetlogin))]     namespace loginpattern.android     {           public class auth0widgetlogin : formsapplicationactivity, loginpattern.iauth0widgetlogin           ...     { 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -