3

I have a method that allows user to follow other twitter account using twitter API, however, this method stopped working since iOS 11.

Because: Social accounts have been removed from Settings in iOS 11. Third-party apps no longer have access to those signed-in accounts. (31687059)

(In the following method, the return value "isGranted" will be false, and error code will be: error 7, from apple.com)

Is there a way to work around this?

static func followAppTwitter(_ twitterScreenName: String) {

    let accountStore = ACAccountStore()
    let twitterType = accountStore.accountType(withAccountTypeIdentifier: ACAccountTypeIdentifierTwitter)

    accountStore.requestAccessToAccounts(with: twitterType, options: nil,
        completion: { (isGranted, error) in
            guard let userAccounts = accountStore.accounts(with: twitterType),
                userAccounts.count > 0 else { return }
            guard let firstActiveTwitterAccount = userAccounts[0] as? ACAccount else { return }

            // Then do a data post to twitter API
            // ......
    })
}
RainCast
  • 4,134
  • 7
  • 33
  • 47

1 Answers1

1

After searching around for a while - I have replaced my code with - https://github.com/mattdonnelly/Swifter SwifterIOS

Michael Rowe
  • 870
  • 2
  • 11
  • 27