Comments (10)
Interesting. I'll have a look in the morning If I get a spare minute or two, feel free to fork and try debug or improve yourself, always happy to have more people contribute
from cordova-device-accounts-v2.
I think the 'only google' is straightforward
android api says:
an optional string array of account types.
, i think leaving the 'com.google' out will give all the options
The not returning problem is maybe related to the fact there is no return value ? and the other methods do.
from cordova-device-accounts-v2.
Can confirm that replacing new String[]{"com.google"} by null, lets you choose between all your accounts. Right now i am struggling with the second issue
from cordova-device-accounts-v2.
I almost figured it out.
You need to set the callbackContext locally and do following
private void getPermissions() {
AccountManager manager = AccountManager.get(cordova.getActivity().getApplicationContext());
Intent accountIntent = manager.newChooseAccountIntent(null, null, null, null, null, null, null);
cordova.setActivityResultCallback(this);
cordova.getActivity().startActivityForResult(accountIntent, VISIBILITY_VISIBLE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent){
if(requestCode == VISIBILITY_VISIBLE && this.callbackContext != null){
this.callbackContext.success("Success");
} else {
this.callbackContext.error("Invalid requestCode: " + requestCode);
}
}
It fires the success callback but reaches the reject of the app.
from cordova-device-accounts-v2.
i managed to write this but it still needs improvements.
Would you mind taking a look ? My Android knowledge is far, far away.
private void getPermissions(String type) {
AccountManager manager = AccountManager.get(cordova.getActivity().getApplicationContext());
Intent accountIntent = manager.newChooseAccountIntent(null, null, new String[]{type}, null, null, null, null);
cordova.setActivityResultCallback(this);
cordova.getActivity().startActivityForResult(accountIntent, VISIBILITY_VISIBLE);
}
private void getPermissions() {
AccountManager manager = AccountManager.get(cordova.getActivity().getApplicationContext());
Intent accountIntent = manager.newChooseAccountIntent(null, null, null, null, null, null, null);
cordova.setActivityResultCallback(this);
cordova.getActivity().startActivityForResult(accountIntent, VISIBILITY_VISIBLE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
if(requestCode == VISIBILITY_VISIBLE && this.callbackContext != null){
this.callbackContext.success("Success " + data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE +" "+ data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME)));
} else {
this.callbackContext.error("Invalid requestCode: " + requestCode);
}
}
This would have the option to give a type argument (instead of the "google.com")
from cordova-device-accounts-v2.
Separating the account type and callback issues #11
from cordova-device-accounts-v2.
This would be much easier to review in a pull request - additionally, I think the getPermissions() function should actually return all accounts, then the type should be handled by the getAccounts() function which already handles the type to receive.
from cordova-device-accounts-v2.
I've been working on making an easy usage guide for this plugin with an ionic application. Check it out here, perhaps we can add this to the examples once we also get this working. https://github.com/xUnholy/cordova-device-accounts-example
from cordova-device-accounts-v2.
Please review and test the following - I've used some of your logic and tweaked it to solve the underlying issue with the promise resolving incorrectly which was a bug. Effectively the promise would be rejected even though internally it resolved.
from cordova-device-accounts-v2.
Pull request can be reviewed here - #12
from cordova-device-accounts-v2.
Related Issues (12)
- Not getting permission popup & no response from plugin HOT 2
- getPermissions() does not return all account types HOT 8
- Setup downloads README badge
- get() returns empty array in Android 10 HOT 9
- How to get selectedAccount from AccountPicker HOT 4
- Get Accounts returning Empty array HOT 2
- there is no flag or identifier which email being selected.
- Ionic 3 : Access to Account Manager not working / this.deviceAccounts.get()
- Update readme with all methods and examples
- Setup CI pipeline
- Support iOS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-device-accounts-v2.