@bonnell: thanks for your reply. It does seem very strange.
Here’s the Objective C code:
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
if (session)
{
NSLog(@"signed in as %@", [session userName]);
TWTRComposer *composer = [[TWTRComposer alloc] init];
[composer setText: text]];
[composer setImage: image];
[composer setURL: url ];
// Called from a UIViewController
[composer showFromViewController:self completion:^(TWTRComposerResult result) {
if (result == TWTRComposerResultCancelled) {
NSLog(@"Tweet composition cancelled");
[[Twitter sharedInstance].sessionStore logOutUserID:[session userID]];
}
else {
NSLog(@"Sending Tweet!");
[[Twitter sharedInstance].sessionStore logOutUserID:[session userID]];
}
}];
}
else
{
NSLog(@"error: %@", [error localizedDescription]);
UIAlertController *noTwitterAlertController = [UIAlertController alertControllerWithTitle:@"Please connect your device to Twitter" message:@"Your device isn't associated with a Twitter account. Please connect to an account in your device settings." preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:noTwitterAlertController animated:YES completion:nil];
}
}];
Here’s the console output:
2016-07-15 10:42:24.756 <AppName>[3201:1707748] signed in as <username>
2016-07-15 10:42:27.753 <AppName>[3201:1707748] Sending Tweet!
2016-07-15 10:56:03.853 <AppName>[3201:1710505] plugin com.apple.share.Twitter.post invalidated
Once this displays the TWTRComposer’s view disappears and the user can continue using the app.
On the device with the Twitter app installed, the tweet is not posted. When the Twitter app launches, it displays an UIAlertView (or UIAlertController styled to Alert) with this title: “Tweet failed to send”, message: “Your Tweet couldn’t be sent and has been saved as a draft.”, options: “Drafts”, “OK”.
What else I can think of that might be relevant so far:
I’m using Xcode 7.3.
The app’s been developed and maintained in Objective C, but if there’s a Swift solution I can use that too.
The app has been developed to support iOS 7, for which Cocoapods has installed TwitterKit 1.15.3. I’ve tried increasing the minimum deployment target to iOS 8.0, so that Cocoapods can install the latest TwitterKit, 2.3.0. This has made no difference to the experienced problem.
The device which successfully tweets is an iPod Touch running iOS 8.4. The device which has Twitter installed and fails is an iPad mini 2 running the latest iOS 9.3.
In the project:
<TwitterKit/TwitterKit.h> is imported in the .m file with the above code.
[Fabric with:@[[Crashlytics class], [Twitter class]]]; is called in the AppDelegate’s application:didFinishLaunchingWithOptions: method.
Both Crashlytics and Twitter have been added to the app’s Info.plist, as dictionaries in the Fabric/Kits array. The dictionary whose KitName is ‘Twitter’ has a KitInfo dictionary containing the app’s consumerKey and consumerSecret.
Any suggestions?