chroa / twitter-connect-plugin

Cordova/PhoneGap plugin to use Twitter Single Sign on
Apache License 2.0
10 stars 16 forks source link

How to call verify_credentials api to get email if user has given permission, we only have function showUsers which does not give email #18

Open vivek0460 opened 6 years ago

fossman83 commented 6 years ago

Did you figure this out?

wichanan commented 6 years ago

Take a look at the code here https://github.com/chroa/twitter-connect-plugin/blob/master/src/ios/TwitterConnect.m https://github.com/chroa/twitter-connect-plugin/blob/master/src/android/TwitterConnect.java

You will see, there is a function called verifyCredentials which will get the user profile with email from Twitter api.

And if you look closely enough you will see it here https://github.com/chroa/twitter-connect-plugin/blob/master/www/TwitterConnect.js

That means you can already access it like this TwitterConnect.verifyCredentials

It is there but it's just not included in the readme file of the repo

chiemekailo commented 5 years ago

Hello @wichanan, I have seen the files you listed above with the embedded functions. My problem is that it is only login(), logout(), and showUser() that are working. All the rest give errors. For example TwitterConnect.openComposer throws

Property 'openComposer' does not exist on type 'TwitterConnect'.

Even my VS code editor highlights this same error. (it underlines the openComposer in red, and on hover it prints the above error to tool tip). Is there something I am doing wrong? the login/logout/showUser all work fine. NB: I have also noticed that only the 3 functions (login(), logout(), and showUser()) are listed in ionicframework's Twitter Connect. Could it be suppressing the other function calls somehow?crazy idea here

wichanan commented 5 years ago

@chiemekailo Maybe my answer was too vague. If you are using ionic framework you can easily access those available functions by editing the

project_dir/node_modules/@ionic-native/twitter-connect/ngx/index.js

//original ionic prototype
TwitterConnect.prototype.showUser = function () { return cordova(this, "showUser", {}, arguments); };
// your custom ionic prototype
TwitterConnect.prototype.verifyCredentials = function () { return cordova(this, "verifyCredentials", {}, arguments); };

and then on the project_dir/node_modules/@ionic-native/twitter-connect/ngx/index.d.ts

export declare class TwitterConnect extends IonicNativePlugin {
    .....

    verifyCredentials(): Promise<any>;
}

and then you should be able to access any available function other than login(), logout(), and showUser().

List of available functions: https://github.com/chroa/twitter-connect-plugin/blob/master/src/ios/TwitterConnect.m https://github.com/chroa/twitter-connect-plugin/blob/master/src/android/TwitterConnect.java