Reputation: 5384
Always getting below error after login success not getting redirected to my app.it is keep on loading.
"Redirecting you back to the application.This may take a few moments."
[TwitterKit] did encounter error with message "Unable to authenticate using the system account.": Error Domain=TWTRLogInErrorDomain Code=0 "User denied access to system accounts." UserInfo={NSLocalizedDescription=User denied access to system accounts., NSLocalizedRecoverySuggestion=Give this user access to the System Twitter account.}
ViewController.m
[[Twitter sharedInstance] startWithConsumerKey:@"myConsumerKey" consumerSecret:@"myConsumerSecret"];
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
if (session) {
TWTRComposer *composer = [[TWTRComposer alloc] init];
[composer setText:@"just setting up my Twitter Kit"];
[composer setImage:[UIImage imageNamed:@"twitterkit"]];
// Called from a UIViewController
[composer showFromViewController:delegate.window.rootViewController completion:^(TWTRComposerResult result) {
if (result == TWTRComposerResultCancelled) {
NSLog(@"Tweet composition cancelled");
}
else {
NSLog(@"Sending Tweet!");
}
}];
} else {
NSLog(@"error: %@", [error localizedDescription]);
}
}];
AppDelegate.m
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
options:(NSDictionary *) options
{
[[Twitter sharedInstance] application:application openURL:url options:options];
return YES;
}
Upvotes: 1
Views: 3925
Reputation: 456
I know this is old but this may help someone, I had the same issue since from iOS 13 we have scenedelegate file. the solution for me was to manage the method in scenedelegate file via the below delegate method for twitter.
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
if let openURLContext = URLContexts.first {
let url = openURLContext.url
let options: [AnyHashable : Any] = [
UIApplication.OpenURLOptionsKey.annotation : openURLContext.options.annotation as Any,
UIApplication.OpenURLOptionsKey.sourceApplication : openURLContext.options.sourceApplication as Any,
UIApplication.OpenURLOptionsKey.openInPlace : openURLContext.options.openInPlace
]
TWTRTwitter.sharedInstance().application(UIApplication.shared, open: url, options: options)
}
}
Upvotes: 2
Reputation: 1207
Starting from iOS 11, Apple has removed social accounts from iOS.
You should use Twitter Kit 3 for iOS.
Refer to Twitter blog https://dev.twitter.com/twitterkit/ios/migrate-social-framework
UPDATE
AppDelegate
import TwitterKit
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Intialize Twitter Kit
Twitter.sharedInstance().start(withConsumerKey:consumer_key, consumerSecret:consumer_secret)
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if Twitter.sharedInstance().application(app, open: url, options: options) {
return true
}
return false
}
ViewController
import TwitterKit
override func viewDidLoad() {
super.viewDidLoad()
Twitter.sharedInstance().logIn(with: self, completion: { (session, error) in
if let sess = session {
print("signed in as \(sess.userName)");
} else {
print("error: \(String(describing: error?.localizedDescription))");
}
})
}
Info.plis
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-{your consumer key}</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>twitter</string>
<string>twitterauth</string>
</array>
Upvotes: 0