31 lines
971 B
Plaintext
31 lines
971 B
Plaintext
//
|
|
// UIViewController+Share.cpp
|
|
// Unity-iPhone
|
|
//
|
|
// Created by Hl Zhang on 2023/3/20.
|
|
//
|
|
|
|
#include <string>
|
|
#import "UIViewController+Share.h"
|
|
@import FBSDKShareKit;
|
|
|
|
@implementation UIViewController (Share)
|
|
|
|
-(void)shareToFacebook:(NSString *)title {
|
|
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
|
|
content.contentURL = [NSURL URLWithString:@"https://www.example.com"];
|
|
content.quote = @"Check out this awesome website!";
|
|
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] initWithViewController:self content:content delegate: nil];
|
|
[dialog show];
|
|
}
|
|
|
|
extern "C" void shareWithFacebook(const char *url) {
|
|
NSString *urlStr = [NSString stringWithCString:url encoding: NSUTF8StringEncoding];
|
|
NSLog(@"share with facebook: %@", urlStr);
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
|
[window.rootViewController shareToFacebook:urlStr];
|
|
});
|
|
}
|
|
@end
|