iOS twitter checking if accounts are available -
am developing app (ios5+) posting on twitter. check if system has twitter account configured, may log in through twitter if account available otherwise presented webview log in (using unofficial-twitter-sdk) or sent settings add twitter account system (but don't way since cannot user app).
the problem approach on simulator can check how many accounts there using
acaccounttype *twitteraccounttype = [_accountstore accounttypewithaccounttypeidentifier:acaccounttypeidentifiertwitter]; // list of twitter accounts , checks nsarray *accountsarray = [_accountstore accountswithaccounttype:twitteraccounttype];
while same code not work on real devices, reporting array empty (since returns accounts gave permission app use twitter).
the second approach using completion handler of -acaccountstore requestaccesstoaccountswithtype:withcompletionhandler: method, in particular
// can user twitter ios accounts, use custom view post content [_accountstore requestaccesstoaccountswithtype:twitteraccounttype withcompletionhandler:^(bool granted, nserror *error) { if (granted) { // post } else { // error? }
but in second case error nil, in of following cases: 1. user did not grant permission use system account 2. there no accounts available
so cannot discriminate between 2 cases in way, therefore don't know if should present user view log in (second case) or fail because did not want log in.
any insight? there workaround?
Comments
Post a Comment