-
Notifications
You must be signed in to change notification settings - Fork 1
/
qtwitter_ios.mm
35 lines (28 loc) · 1.1 KB
/
qtwitter_ios.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "qtwitter.h"
#include <QQuickView>
#include <QDebug>
#include <QGuiApplication>
#include <qpa/qplatformnativeinterface.h>
#import <TwitterKit/TwitterKit.h>
#import <Fabric/Fabric.h>
void QTwitter::authenticate() {
[[Twitter sharedInstance] startWithConsumerKey:(consumerKey.toNSString()) consumerSecret:consumerSecret.toNSString()];
[Fabric with:@[[Twitter sharedInstance]]];
}
void QTwitter::compose( QString message, QUrl link, QUrl localImage ) {
UIView *view = static_cast<UIView *>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("uiview",mainView));
UIViewController *qtController = [[view window] rootViewController];
TWTRComposer *composer = [[TWTRComposer alloc] init];
[composer setText:(message.toNSString())];
[composer setURL:(link.toNSURL())];
//[composer setImage:[UIImage imageNamed:@"fabric"]];
// Called from a UIViewController
[composer showFromViewController:qtController completion:^(TWTRComposerResult result) {
if (result == TWTRComposerResultCancelled) {
NSLog(@"Tweet composition cancelled");
}
else {
NSLog(@"Sending Tweet!");
}
}];
}