<key>CFBundleDevelopmentRegion</key>
<string>CHT</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1234567890</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>1234567890</string>
<key>FacebookDisplayName</key>
<string>Demo</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
<string>fbapi</string>
<string>fbshareextension</string>
</array>
注意:FacebookAppID、FacebookDisplayName必须与facebook后台一致
void friendListCallBack(bool result,const char* jsonStr)
{
if (result) {
NSString *dataStr = [NSString stringWithUTF8String:jsonStr];
NSData *data = [dataStr dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary* dic =[NSJSONSerialization
JSONObjectWithData:data //1
options:kNilOptions
error:&error];
if (error) {
//获取好友列表失败!
return;
}
NSArray *array = [dic objectForKey:@"data"];
for (int i=0; i<[array count]; i++) {
NSDictionary *tmpDic = [array objectAtIndex:i];
NSString *name = [tmpDic objectForKey:@"name"]; //facebook用户名称
NSString *userId = [tmpDic objectForKey:@"id"]; //facebook用户id
NSString *Ourpalm_ID = [tmpDic objectForKey:@"Ourpalm_ID"];//掌趣用户id
}
NSNumber *next = [dic objectForKey:@"next"]; //用于判断是否还有下一页数据
} else {
//获取好友列表失败!
}
}
数据格式说明:
{
count = 1;
data = (
{
"Ourpalm_ID" = 掌趣用户id;
id = facebook用户id;
name = facebook用户名称;
picture = {
data = {
url = "用户图片地址";
};
};
},
);
next = 0; //是否有下一页
previous = 0; //是否有上一页
}
//必须先调用此接口获取app好友首页数据
OPGameSDK::GetInstance().ChannelSpreads("FB_GetAppFriendList",(void*)friendListCallBack);
//获取下一页
OPGameSDK::GetInstance().ChannelSpreads("FB_GetFriendList_Next");
void fbShareCallback(int errorCode, const char* jsonStr)
{
OPUserType type = OPGameSDK::GetInstance().mShareType;
if (type == kFBShare) {
cout<<"facebook分享链接"<<endl;
}else if(type == kFBShareImage){
cout<<"facebook分享图片"<<endl;
}else if(type == kFBInviteFriend){
cout<<"facebook邀请"<<endl;
}
if (errorCode == 1) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else if (errorCode == 0){
OPSDK::GetInstance().ShowMsg("取消分享");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
oid OPSDK::inviteFriend()
{
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//邀请好友
Json::Value shareJson;
shareJson["title"] = Json::Value("title");//标题
shareJson["message"] = Json::Value("message");//消息
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBInviteFriend);
}
回调数据格式:
{
request = 1501199046846374;
to = (
364167064041191 //FB好友的用户id
);
"to[0]" = 364167064041191; //FB好友的用户id
}
void OPSDK::shareLink()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
Json::Value shareJson;
shareJson["link"] = Json::Value("https://developers.facebook.com/docs/ios/share/");
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShare);
}
void OPSDK::shareImage()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//分享
Json::Value shareJson;
//网络图片
//shareJson["picture"] = Json::Value("http://content.game-bean.com/image/98kof/pc/pc_banner01.jpg");
//本地图片
NSString *filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"localPic.png"];
shareJson["picture"] = Json::Value([filePath UTF8String]);
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShareImage);
}
//com.openinstall.APP_KEY请与运营人员获取
<key>com.openinstall.APP_KEY</key>
<string>sw1ij8</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>openinstall</string>
<key>CFBundleURLSchemes</key>
<array>
<string>sw1ij8</string>
</array>
</dict>
</array>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:sw1ij8.openinstall.io</string>
</array>
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler{
//处理通过openinstall一键唤起App时传递的数据
OPGameSDK::GetInstance().ChannelSpreads("ApplicationContinueUserActivity",(void*)application,(void*)userActivity);
return YES;
}
void openInstallParamsCallback(const char* type, const char* jsonStr)
{
if (strcmp(type, "InstallParams") == 0) {
//安装获取动态参数
}else if (strcmp(type, "WakeUpParams") == 0) {
//唤醒时获取动态参数
}
}
//设置openinstall回调接口
OPGameSDK::GetInstance().ChannelSpreads("GetOpenInstallParams",(void*)openInstallParamsCallback);
void openInstallShareCallback(bool result, const char* jsonStr)
{
if (result) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
void OPSDK::ShareOpenInstall()
{
Json::Value shareJson;
shareJson["text"] = Json::Value("分享文本");
shareJson["sharekey"] = Json::Value("abcdef");
Json::FastWriter fast_writer;
string tmp = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ChannelSpreads("ShareOpenInstall",(void*)openInstallShareCallback,tmp.c_str());
}
<key>CFBundleDevelopmentRegion</key>
<string>EN</string>
true:默认值,计费弹出绑定FB界面
false:计费不弹出绑定FB界面
<key>chargeBindSwitch</key>
<false/>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1234567890</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>1234567890</string>
<key>FacebookDisplayName</key>
<string>Demo</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
<string>fbapi</string>
<string>fbshareextension</string>
</array>
注意:FacebookAppID、FacebookDisplayName必须与facebook后台一致
void friendListCallBack(bool result,const char* jsonStr)
{
if (result) {
NSString *dataStr = [NSString stringWithUTF8String:jsonStr];
NSData *data = [dataStr dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary* dic =[NSJSONSerialization
JSONObjectWithData:data //1
options:kNilOptions
error:&error];
if (error) {
//获取好友列表失败!
return;
}
NSArray *array = [dic objectForKey:@"data"];
for (int i=0; i<[array count]; i++) {
NSDictionary *tmpDic = [array objectAtIndex:i];
NSString *name = [tmpDic objectForKey:@"name"]; //facebook用户名称
NSString *userId = [tmpDic objectForKey:@"id"]; //facebook用户id
NSString *Ourpalm_ID = [tmpDic objectForKey:@"Ourpalm_ID"];//掌趣用户id
}
NSNumber *next = [dic objectForKey:@"next"]; //用于判断是否还有下一页数据
} else {
//获取好友列表失败!
}
}
数据格式说明:
{
count = 1;
data = (
{
"Ourpalm_ID" = 掌趣用户id;
id = facebook用户id;
name = facebook用户名称;
picture = {
data = {
url = "用户图片地址";
};
};
},
);
next = 0; //是否有下一页
previous = 0; //是否有上一页
}
//必须先调用此接口获取app好友首页数据
OPGameSDK::GetInstance().ChannelSpreads("FB_GetAppFriendList",(void*)friendListCallBack);
//获取下一页
OPGameSDK::GetInstance().ChannelSpreads("FB_GetFriendList_Next");
void fbShareCallback(int errorCode, const char* jsonStr)
{
OPUserType type = OPGameSDK::GetInstance().mShareType;
if (type == kFBShare) {
cout<<"facebook分享链接"<<endl;
}else if(type == kFBShareImage){
cout<<"facebook分享图片"<<endl;
}else if(type == kFBInviteFriend){
cout<<"facebook邀请"<<endl;
}
if (errorCode == 1) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else if (errorCode == 0){
OPSDK::GetInstance().ShowMsg("取消分享");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
oid OPSDK::inviteFriend()
{
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//邀请好友
Json::Value shareJson;
shareJson["title"] = Json::Value("title");//标题
shareJson["message"] = Json::Value("message");//消息
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBInviteFriend);
}
回调数据格式:
{
request = 1501199046846374;
to = (
364167064041191 //FB好友的用户id
);
"to[0]" = 364167064041191; //FB好友的用户id
}
void OPSDK::shareLink()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
Json::Value shareJson;
shareJson["link"] = Json::Value("https://developers.facebook.com/docs/ios/share/");
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShare);
}
void OPSDK::shareImage()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//分享
Json::Value shareJson;
//网络图片
//shareJson["picture"] = Json::Value("http://content.game-bean.com/image/98kof/pc/pc_banner01.jpg");
//本地图片
NSString *filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"localPic.png"];
shareJson["picture"] = Json::Value([filePath UTF8String]);
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShareImage);
}
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"GetBindStatus",@"ChannelSpreadName", nil];
bool bindStatus = OPGameSDK::GetInstance().GetChannelSpreads((void*)dic);
if (bindStatus) {
OPSDK::GetInstance().ShowMsg("快登已绑定第三方账号");
}else{
OPSDK::GetInstance().ShowMsg("快登未绑定第三方账号");
}
void bindAccountCallBack(const char* type,const char* jsonStr)
{
if (strcmp(type, "BindAccountSuccess") == 0) {
//绑定成功
}else if (strcmp(type, "UnBindAccountSuccess") == 0){
//解绑成功
}
}
OPGameSDK::GetInstance().ChannelSpreads("SetBindAccountCallback",(void*)bindAccountCallBack);
void OPSDK::ShowBindAccount()
{
OPGameSDK::GetInstance().ChannelSpreads("ShowBindAccount");
}
void switchAccountCallBack(const char* type,const char* jsonStr)
{
if (strcmp(type, "SwitchAccountSuccess") == 0) {
//切换成功
}
}
OPGameSDK::GetInstance().ChannelSpreads("SetSwitchAccountCallback",(void*)switchAccountCallBack);
void OPSDK::ShowSwitchAccount()
{
OPGameSDK::GetInstance().ChannelSpreads("ShowSwitchAccount");
}
void bindEmailCallback(bool result, const char* jsonStr)
{
if(result){
Json::Reader json_reader;
Json::Value json_object;
if (!json_reader.parse(jsonStr, json_object)){
return;
}
string emailName = json_object["emailName"].asString();
}
}
void OPSDK::ShowBindEmail()
{
OPGameSDK::GetInstance().ChannelSpreads("ShowBindEmail",(void*)bindEmailCallback);
}
数据示例:
{
"status":"1",
"code":"",
"emailName":"xxx@xxx",
"desc":""
}
该接口暂时只给coc用,sdk登录成功后调用此接口,游戏客户端传入掌趣uid及其它信息,sdk去用户中心校验此uid是否存在,如果校验成功,sdk会返回此uid对应的登录数据,同时保存本地快登标识,后续再次调用sdk登录登录时,SDK拿新的本地快登标识进行登录。
如果不存在,会返回校验的错误信息。
void checkLoginUserIdCallback(bool result,const char* jsonStr)
{
cout<<"*********checkLoginUserIdCallback********"<<endl;
if (result) {
cout<<jsonStr<<endl;
//userId校验成功,进入登录页面,重新登陆开始游戏
dispatch_async(dispatch_get_main_queue(), ^{
OPSDK::GetInstance().ShowMsg("userId校验成功,进入登录页面,重新登陆开始游戏");
});
}else{
//失败
dispatch_async(dispatch_get_main_queue(), ^{
OPSDK::GetInstance().ShowMsg("userId校验失败");
});
}
}
void OPSDK::CheckLoginUserId()
{
Json::Value json;
json["userId"] = userId;//掌趣用户id
json["timestamp"] = timestamp;//时间戳
json["sign"] = sign;//签名,md5(userId+timestamp+secretkey),secretkey由运营提供
Json::FastWriter fast_writer;
string userInfo = fast_writer.write(json);
OPGameSDK::GetInstance().ChannelSpreads("CheckLoginUserId",(void*)checkLoginUserIdCallback,(void*)userInfo.c_str());
}
OPGameSDK::GetInstance().GetDid();
OPGameSDK::GetInstance().GetCallbackInfo();
OPGameSDK::GetInstance().UpdateClientVersion("1.0.0");
OPSDKUserInfo userInfo;
userInfo.mGame_RoleId = "1234"; //游戏角色id(必填)
userInfo.mGame_RoleName = "rolename"; //游戏角色名称(必填)
userInfo.mGame_ServerId = "1"; //游戏服务器id(必填)
userInfo.mGame_ServerName = "s1"; //游戏服务器名称(必填)
userInfo.mGame_RoleLevel = "1"; //游戏角色等级(可选)
userInfo.mGame_RoleVipLevel = "1"; //游戏角色vip等级(可选)
userInfo.mAccountId = "1234564645";
userInfo.mGameLanguage = "en_GB";
OPGameSDK::GetInstance().SetUserInfo(userInfo);
Json::Value data;
data["step"] = Json::Value("1013");
data["action"] = Json::Value("LOGIN_RIGISTER");
Json::FastWriter fast_writer;
string dataStr = fast_writer.write(data);
OPGameSDK::GetInstance().TrackEvent("create_filter", dataStr.c_str());
OPGameSDK::GetInstance().TrackAttributionEvent("create_role");
Json::Value data;
data["content_id"] = "test_propId"; //商品ID
data["currency"] = "USD"; //货币类型
data["revenue"] = 9.99; //商品价格
Json::FastWriter fast_writer;
string dataStr = fast_writer.write(data);
OPGameSDK::GetInstance().TrackAttributionEvent("purchase",dataStr.c_str());
<key>CFBundleDevelopmentRegion</key>
<string>JAPAN</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-APIKey</string>
</array>
</dict>
</array>
<key>APIKey</key>
<string>Fn9asdfasdfasdfqJw</string>
<key>APISecret</key>
<string>cHg4vasdfasdfasdfasfdsfasdfasdfafdaasdfgx27Qbvfwu</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>twitter</string>
<string>twitterauth</string>
</array>
void twitterShareCallback(int errorCode, const char* jsonStr)
{
if (errorCode == 1) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else if (errorCode == 0){
OPSDK::GetInstance().ShowMsg("取消分享");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
void OPSDK::shareLink()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(twitterShareCallback);
Json::Value shareJson;
shareJson["link"] = Json::Value("http://www.baidu.com");
shareJson["picture"] = Json::Value("//content.gamebean.com/image/ourpalmcn/logo.jpg");
shareJson["description"] = Json::Value("Twitter分享测试!");
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str());
}
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
OPGameSDK::GetInstance().ChannelSpreads("SetAdvertiserTrackingEnabled");
}else{
OPGameSDK::GetInstance().ChannelSpreads("SetAdvertiserTrackingDisabled");
}
}];
void fbShareCallback(int errorCode, const char* jsonStr)
{
if (errorCode == 1) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else if (errorCode == 0){
OPSDK::GetInstance().ShowMsg("取消分享");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
void OPSDK::fbShareLink()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//分享
Json::Value shareJson;
shareJson["link"] = Json::Value("http://www.baidu.com");
shareJson["picture"] = Json::Value("//content.gamebean.com/image/ourpalmcn/logo.jpg");
shareJson["description"] = Json::Value("FB分享测试!");
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShare);
}
void OPSDK::fbShareImage()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//分享
Json::Value shareJson;
//网络图片
// shareJson["picture"] = Json::Value("http://content.game-bean.com/image/98kof/pc/pc_banner01.jpg");
//本地图片
NSString *filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"localPic.png"];
shareJson["picture"] = Json::Value([filePath UTF8String]);
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShareImage);
}
void OPSDK::fbShareInvite()
{
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//分享
Json::Value shareJson;
shareJson["title"] = Json::Value("title"); //标题
shareJson["message"] = Json::Value("message"); //消息
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBInviteFriend);
}
//com.openinstall.APP_KEY请与运营人员获取
<key>com.openinstall.APP_KEY</key>
<string>sw1ij8</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>openinstall</string>
<key>CFBundleURLSchemes</key>
<array>
<string>sw1ij8</string>
</array>
</dict>
</array>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:sw1ij8.openinstall.io</string>
</array>
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler{
//处理通过openinstall一键唤起App时传递的数据
OPGameSDK::GetInstance().ChannelSpreads("ApplicationContinueUserActivity",(void*)application,(void*)userActivity);
return YES;
}
void openInstallParamsCallback(const char* type, const char* jsonStr)
{
if (strcmp(type, "InstallParams") == 0) {
//安装获取动态参数
}else if (strcmp(type, "WakeUpParams") == 0) {
//唤醒时获取动态参数
}
}
//设置openinstall回调接口
OPGameSDK::GetInstance().ChannelSpreads("GetOpenInstallParams",(void*)openInstallParamsCallback);
void openInstallShareCallback(bool result, const char* jsonStr)
{
if (result) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
void OPSDK::ShareOpenInstall()
{
Json::Value shareJson;
shareJson["text"] = Json::Value("分享文本");
shareJson["sharekey"] = Json::Value("abcdef");
Json::FastWriter fast_writer;
string tmp = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ChannelSpreads("ShareOpenInstall",(void*)openInstallShareCallback,tmp.c_str());
}
<key>CFBundleDevelopmentRegion</key>
<string>CHT</string>
<key>KakaoGameConfiguration</key>
<dict>
<key>AppId</key>
<string>xxxx</string>
<key>AppSecret</key>
<string>3daxxxxxxxxxxxxxxxxxd9b</string>
<key>AppVersion</key>
<string>1.0.0</string>
<key>DebugLevel</key>
<string>verbose</string>
<key>ServerType</key>
<string>real</string>
</dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1234567890</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>1234567890</string>
<key>FacebookDisplayName</key>
<string>Demo</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
<string>fbapi</string>
<string>fbshareextension</string>
</array>
注意:FacebookAppID、FacebookDisplayName必须与facebook后台一致
void friendListCallBack(bool result,const char* jsonStr)
{
if (result) {
NSString *dataStr = [NSString stringWithUTF8String:jsonStr];
NSData *data = [dataStr dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary* dic =[NSJSONSerialization
JSONObjectWithData:data //1
options:kNilOptions
error:&error];
if (error) {
//获取好友列表失败!
return;
}
NSArray *array = [dic objectForKey:@"data"];
for (int i=0; i<[array count]; i++) {
NSDictionary *tmpDic = [array objectAtIndex:i];
NSString *name = [tmpDic objectForKey:@"name"]; //facebook用户名称
NSString *userId = [tmpDic objectForKey:@"id"]; //facebook用户id
NSString *Ourpalm_ID = [tmpDic objectForKey:@"Ourpalm_ID"];//掌趣用户id
}
NSNumber *next = [dic objectForKey:@"next"]; //用于判断是否还有下一页数据
} else {
//获取好友列表失败!
}
}
数据格式说明:
{
count = 1;
data = (
{
"Ourpalm_ID" = 掌趣用户id;
id = facebook用户id;
name = facebook用户名称;
picture = {
data = {
url = "用户图片地址";
};
};
},
);
next = 0; //是否有下一页
previous = 0; //是否有上一页
}
//必须先调用此接口获取app好友首页数据
OPGameSDK::GetInstance().ChannelSpreads("FB_GetAppFriendList",(void*)friendListCallBack);
//获取下一页
OPGameSDK::GetInstance().ChannelSpreads("FB_GetFriendList_Next");
//必须先调用此接口获取非app好友首页数据
OPGameSDK::GetInstance().ChannelSpreads("FB_GetInviteFriendList",(void*)friendListCallBack);
//获取下一页
OPGameSDK::GetInstance().ChannelSpreads("FB_GetFriendList_Next");
void fbShareCallback(int errorCode, const char* jsonStr)
{
OPUserType type = OPGameSDK::GetInstance().mShareType;
if (type == kFBShare) {
cout<<"facebook分享链接"<<endl;
}else if(type == kFBShareImage){
cout<<"facebook分享图片"<<endl;
}else if(type == kFBInviteFriend){
cout<<"facebook邀请"<<endl;
}
if (errorCode == 1) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else if (errorCode == 0){
OPSDK::GetInstance().ShowMsg("取消分享");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
oid OPSDK::inviteFriend(const char* receiverid)
{
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//邀请好友
Json::Value shareJson;
shareJson["title"] = Json::Value("title");//标题
shareJson["message"] = Json::Value("message");//消息
shareJson["receiverId"] = Json::Value(receiverid);//facebook好友ID
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBInviteFriend);
}
回调数据格式:
{
request = 1501199046846374;
to = (
364167064041191 //FB好友的用户id
);
"to[0]" = 364167064041191; //FB好友的用户id
}
void OPSDK::shareLink()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
Json::Value shareJson;
shareJson["link"] = Json::Value("https://developers.facebook.com/docs/ios/share/");
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShare);
}
void OPSDK::shareImage()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//分享
Json::Value shareJson;
//网络图片
//shareJson["picture"] = Json::Value("http://content.game-bean.com/image/98kof/pc/pc_banner01.jpg");
//本地图片
NSString *filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"localPic.png"];
shareJson["picture"] = Json::Value([filePath UTF8String]);
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShareImage);
}
//com.openinstall.APP_KEY请与运营人员获取
<key>com.openinstall.APP_KEY</key>
<string>sw1ij8</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>openinstall</string>
<key>CFBundleURLSchemes</key>
<array>
<string>sw1ij8</string>
</array>
</dict>
</array>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:sw1ij8.openinstall.io</string>
</array>
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler{
//处理通过openinstall一键唤起App时传递的数据
OPGameSDK::GetInstance().ChannelSpreads("ApplicationContinueUserActivity",(void*)application,(void*)userActivity);
return YES;
}
void openInstallParamsCallback(const char* type, const char* jsonStr)
{
if (strcmp(type, "InstallParams") == 0) {
//安装获取动态参数
}else if (strcmp(type, "WakeUpParams") == 0) {
//唤醒时获取动态参数
}
}
//设置openinstall回调接口
OPGameSDK::GetInstance().ChannelSpreads("GetOpenInstallParams",(void*)openInstallParamsCallback);
void openInstallShareCallback(bool result, const char* jsonStr)
{
if (result) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
void OPSDK::ShareOpenInstall()
{
Json::Value shareJson;
shareJson["text"] = Json::Value("分享文本");
shareJson["sharekey"] = Json::Value("abcdef");
Json::FastWriter fast_writer;
string tmp = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ChannelSpreads("ShareOpenInstall",(void*)openInstallShareCallback,tmp.c_str());
}
<key>CFBundleDevelopmentRegion</key>
<string>THAI</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>boundleId</string>
<key>CFBundleURLSchemes</key>
<array>
<string>line3rdp.boundleId</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1234567890</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>1234567890</string>
<key>FacebookDisplayName</key>
<string>Demo</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>lineauth</string>
<string>line3rdp.boundleId</string>
<string>fbauth2</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>access.line.me</key>
<dict>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>api.line.me</key>
<dict>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>dl.profile.line.naver.jp</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>lcs.naver.jp</key>
<dict>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>obs.line-apps.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>scdn.line-apps.com</key>
<dict>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
注意:FacebookAppID、FacebookDisplayName必须与facebook后台一致
void friendListCallBack(bool result,const char* jsonStr)
{
if (result) {
NSString *dataStr = [NSString stringWithUTF8String:jsonStr];
NSData *data = [dataStr dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary* dic =[NSJSONSerialization
JSONObjectWithData:data //1
options:kNilOptions
error:&error];
if (error) {
//获取好友列表失败!
return;
}
NSArray *array = [dic objectForKey:@"data"];
for (int i=0; i<[array count]; i++) {
NSDictionary *tmpDic = [array objectAtIndex:i];
NSString *nickname = [tmpDic objectForKey:@"displayName"];
NSString *user_id = [tmpDic objectForKey:@"mid"];
NSString *profile_image_url = [tmpDic objectForKey:@"pictureUrl"];
NSLog(@"用户名:%@,用户id:%@,用户头像地址:%@",nickname,user_id,profile_image_url
);
} else {
//获取好友列表失败!
}
}
void OPSDK::getFriendList()
{
//startIndex 第几页. (最小值为 1)
//display 每页显示多少. (最小值为 1, 最大值为 500)
//type:0:所有好友 1;app好友 2:非app好友
OPGameSDK::GetInstance().GetFriendsList(friendListCallBack,1,50);
}
void fbShareCallback(int errorCode, const char* jsonStr)
{
OPUserType type = OPGameSDK::GetInstance().mShareType;
if (type == kFacebook_Type) {
cout<<"facebook分享"<<endl;
}else if(type == kLine_SendMsg){
cout<<"line 分享"<<endl;
}else if(type == kLine_Timeline){
cout<<"line timeline"<<endl;
}
if (errorCode == 1) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else if (errorCode == 0){
OPSDK::GetInstance().ShowMsg("取消分享");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
void OPSDK::sendMsg(const char* receiverid)
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//Line分享
Json::Value shareJson;
shareJson["templateId"] = Json::Value("msg_line_game_template_7"); //模板ID
shareJson["receiverId"] = Json::Value(receiverid); //好友ID
shareJson["text"] = Json::Value("OPText");
shareJson["subtext"] = Json::Value("OPSubtext");
shareJson["alttext"] = Json::Value("OPAltText");
shareJson["linktext"] = Json::Value("OPLinktext");//有长度限制,不能超过13个字符,注意该linktext非链接而是一个标题
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kLine_SendMsg);
}
void OPSDK::sendTimeline()
{
if (OPGameSDK::GetInstance().IsLogin() == false) {
ShowMsg("未登录");
return;
}
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//timeline
Json::Value shareJson;
shareJson["styleType"] = Json::Value("A1"); //必填
shareJson["feedNo"] = Json::Value("1"); //必填
shareJson["postText"] = Json::Value("大家一起来玩游戏"); //必填
shareJson["titleText"] = Json::Value("titleText"); //必填
shareJson["mainText"] = Json::Value("mainText"); //必填
shareJson["subText"] = Json::Value("subText"); //必填
shareJson["thumbnail_url"] = Json::Value("//content.gamebean.com/image/ourpalmcn/logo.jpg");//必填
shareJson["thumbnail_width"] = Json::Value("100"); //必填
shareJson["thumbnail_height"] = Json::Value("100"); //必填
shareJson["dynamicobjs_object"] = Json::Value("1"); //可选
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kLine_Timeline);
}
void sessionInvalidCallBack(bool result,const char* jsonStr)
{
if (result) {
//session 失效
cout<<"**********session 失效**********"<<endl;
}else{
//session 有效
cout<<"**********session 有效**********"<<endl;
}
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
OPGameSDK::GetInstance().SessionInvalidCallBack(sessionInvalidCallBack);
}
void fbShareCallback(int errorCode, const char* jsonStr)
{
OPUserType type = OPGameSDK::GetInstance().mShareType;
if (type == kFacebook_Type) {
cout<<"facebook分享"<<endl;
}else if(type == kLine_SendMsg){
cout<<"line 分享"<<endl;
}else if(type == kLine_Timeline){
cout<<"line timeline"<<endl;
}
if (errorCode == 1) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else if (errorCode == 0){
OPSDK::GetInstance().ShowMsg("取消分享");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
void OPSDK::share()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
Json::Value shareJson;
shareJson["link"] = Json::Value("https://developers.facebook.com/docs/ios/share/");
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFacebook_Type);
}
<key>CFBundleDevelopmentRegion</key>
<string>EN</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1234567890</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>1234567890</string>
<key>FacebookDisplayName</key>
<string>Demo</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
<string>fbapi</string>
<string>fbshareextension</string>
</array>
注意:FacebookAppID、FacebookDisplayName必须与facebook后台一致
OPGameSDK::GetInstance().ChannelSpreads("ShowAppReview",
(void*)"itms-apps://itunes.apple.com/cn/app/id1207224964?mt=8&action=write-review");
void fbShareCallback(int errorCode, const char* jsonStr)
{
OPUserType type = OPGameSDK::GetInstance().mShareType;
if (type == kFBShare) {
cout<<"facebook分享链接"<<endl;
}else if(type == kFBShareImage){
cout<<"facebook分享图片"<<endl;
}else if(type == kFBInviteFriend){
cout<<"facebook邀请"<<endl;
}
if (errorCode == 1) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else if (errorCode == 0){
OPSDK::GetInstance().ShowMsg("取消分享");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
在Info.plist文件中设置Facebook好友权限
<key>Ourpalm_facebook_friends</key>
<false/>
注意:默认设置为支持好友权限;true:需要邀请好友权限;false:无需邀请好友权限
void OPSDK::inviteFriend()
{
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//邀请好友
Json::Value shareJson;
shareJson["title"] = Json::Value("title");//标题
shareJson["message"] = Json::Value("message");//消息
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBInviteFriend);
}
回调数据格式:
{
request = 1501199046846374;
to = (
364167064041191 //FB好友的用户id
);
"to[0]" = 364167064041191; //FB好友的用户id
}
void OPSDK::shareLink()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
Json::Value shareJson;
shareJson["link"] = Json::Value("https://developers.facebook.com/docs/ios/share/");
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShare);
}
void OPSDK::shareImage()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//分享
Json::Value shareJson;
//网络图片
//shareJson["picture"] = Json::Value("http://content.game-bean.com/image/98kof/pc/pc_banner01.jpg");
//本地图片
NSString *filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"localPic.png"];
shareJson["picture"] = Json::Value([filePath UTF8String]);
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShareImage);
}
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-7601182028383771~5697130414</string>
<key>OPIronSourceAppkey</key>
<string>cf297995</string>
void adResultCallBack(const char* adType,const char* statusType)
{
if (adType && statusType) {
if (strcmp(adType, "IronSourceRewardedVideo") == 0 ) {
//IronSource视频广告
if (strcmp(statusType, "RewardedVideoOpen") == 0) {
//广告开始展示
}else if (strcmp(statusType, "RewardedVideoReceivePlacement") == 0){
//广告结束播放
}else if (strcmp(statusType, "RewardedVideoPlayFailed") == 0){
//广告播放失败
}else if (strcmp(statusType, "RewardedVideoClose") == 0){
//用户关闭广告
}else if (strcmp(statusType, "RewardedVideoClick") == 0){
//用户点击广告
}
}
}
}
void OPSDK::shareImage()
{
OPGameSDK::GetInstance().ChannelSpreads("ShowIronSourceRewardedVideo",(void*)adResultCallBack);
}
//com.openinstall.APP_KEY请与运营人员获取
<key>com.openinstall.APP_KEY</key>
<string>po32ce</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>openinstall</string>
<key>CFBundleURLSchemes</key>
<array>
<string>po32ce</string>
</array>
</dict>
</array>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:po32ce.openinstall.io</string>
</array>
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler{
//处理通过openinstall一键唤起App时传递的数据
OPGameSDK::GetInstance().ChannelSpreads("ApplicationContinueUserActivity",(void*)application,(void*)userActivity);
return YES;
}
void openInstallParamsCallback(const char* type, const char* jsonStr)
{
if (strcmp(type, "InstallParams") == 0) {
//安装获取动态参数
}else if (strcmp(type, "WakeUpParams") == 0) {
//唤醒时获取动态参数
}
}
//设置openinstall回调接口
OPGameSDK::GetInstance().ChannelSpreads("GetOpenInstallParams",(void*)openInstallParamsCallback);
void openInstallShareCallback(bool result, const char* jsonStr)
{
if (result) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
void OPSDK::ShareOpenInstall()
{
Json::Value shareJson;
shareJson["text"] = Json::Value("分享文本");
shareJson["sharekey"] = Json::Value("abcdef");
Json::FastWriter fast_writer;
string tmp = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ChannelSpreads("ShareOpenInstall",(void*)openInstallShareCallback,tmp.c_str());
}
<key>CFBundleDevelopmentRegion</key>
<string>CHT</string>
<key>client_id</key>
<string>ebb2effb-775b-4ea9-a958-9bbd7b2cff3f</string>
<key>client_secret</key>
<string>a44927cf-c49d-4e4c-a6c6-44d21bd30b94</string>
<key>service_code</key>
<string>SVC038</string>
<key>mocaa_region</key>
<string>GLOBAL</string>
<key>FacebookAppID</key>
<string>239325303651180</string>
<key>FacebookDisplayName</key>
<string>Global-MU-Origin-2</string>
<key>NewRelicAppToken</key>
<string>AAd6dc516f33bdbeb032a8afbc6e56bb2923893550</string>
注意:FacebookAppID、FacebookDisplayName必须与facebook后台一致
<key>LSApplicationQueriesSchemes</key>
<array>
<string>naversearchapp</string>
<string>naversearchthirdlogin</string>
<string>fbapi</string>
<string>fbauth2</string>
<string>fb-messenger-api</string>
<string>fbshareextension</string>
<string>twitter</string>
<string>twitterauth</string>
<string>lineauth</string>
<string>line3rdp.com.webzen.mocaa.nativesample</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>vk.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
OPGameSDK::GetInstance().ChannelSpreads("ShowNotice");
OPGameSDK::GetInstance().ChannelSpreads("ShowBanner");
OPGameSDK::GetInstance().ChannelSpreads("ShowWebview",(void*)"http://bbs.0708.com");
OPGameSDK::GetInstance().ChannelSpreads("ShowPrivacyPolicy");
OPGameSDK::GetInstance().ChannelSpreads("ShowServicePolicy");
void changePartnerCallBack(int errCode,const char* jsonStr)
{
if (errCode == 1) {
//已经成功转换成正式账号,请用正式账号重新登陆游戏
}else if (errCode == 2){
//该帐号已有其他角色, 请用其他帐号进行转换。
}
}
OPGameSDK::GetInstance().ChannelSpreads("ShowChangePartner",(void*)changePartnerCallBack);
NSArray *propIds = [NSArray arrayWithObjects:@"gmo2_150diamonds",@"gmo2_1250diamonds", nil];
OPGameSDK::GetInstance().InitBillingStore((void *)propIds);
NSMutableDictionary *pushDic = [[[NSMutableDictionary alloc] init] autorelease];
[pushDic setValue:[NSNumber numberWithBool:true] forKey:@"pushAllow"];
[pushDic setValue:[NSNumber numberWithBool:false] forKey:@"gamepushAllow"];
[pushDic setValue:[NSNumber numberWithBool:false] forKey:@"nightpushAllow"];
[pushDic setValue:[NSNumber numberWithBool:false] forKey:@"custompushAllow"];
OPGameSDK::GetInstance().RegistPushNotification((void*)pushDic);
void disconnectCallBack(bool result,const char* jsonStr)
{
}
OPGameSDK::GetInstance().ChannelSpreads("Disconnect",(void*)disconnectCallBack);
<key>CFBundleDevelopmentRegion</key>
<string>JAPAN</string>
<key>Kalends_AppID</key>
<string>4250</string>
<key>FacebookAppID</key>
<string>2294515914208845</string>
<key>FacebookDisplayName</key>
<string>Global-MU-Origin-2</string>
注意:FacebookAppID、FacebookDisplayName必须与facebook后台一致
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbapi20160328</string>
<string>fbauth</string>
<string>fbauth2</string>
<string>fb-messenger-api20140430</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb2294515914208845</string>
</array>
</dict>
</array>
void bindAccountCallBack(int code,const char* jsonStr)
{
if(code == 1){
OPSDK::GetInstance().ShowMsg("绑定成功");
}else if(code == 2){
OPSDK::GetInstance().ShowMsg("账号已继承请重新登录");
}else{
OPSDK::GetInstance().ShowMsg("绑定失败");
}
}
OPGameSDK::GetInstance().ChannelSpreads("BindAccount",(void*)bindAccountCallBack);
void unbindAccountCallBack(bool result,const char* jsonStr)
{
if(result){
OPSDK::GetInstance().ShowMsg("解绑成功");
}else{
OPSDK::GetInstance().ShowMsg("解绑失败");
}
}
OPGameSDK::GetInstance().ChannelSpreads("UnbindAccount",(void*)unbindAccountCallBack);
OPGameSDK::GetInstance().ChannelSpreads("ShowWebview",(void*)"https://csm.web.koramgame.co.jp/?act=index.ask&pios=4250&pandroid=4250");
<key>CFBundleDevelopmentRegion</key>
<string>RU</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb2460230330662969</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>vk6984431</string>
<key>CFBundleURLSchemes</key>
<array>
<string>vk6984431</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>2460230330662969</string>
<key>FacebookDisplayName</key>
<string>MU ORIGIN 2 - RU - iOS</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
<string>fbapi</string>
<string>fbshareextension</string>
<string>vk</string>
<string>vk-share</string>
<string>vkauthorize</string>
</array>
注意:FacebookAppID、FacebookDisplayName必须与facebook后台一致
OPGameSDK::GetInstance().ChannelSpreads("ShowAppReview",
(void*)"itms-apps://itunes.apple.com/cn/app/id1207224964?mt=8&action=write-review");
void fbShareCallback(int errorCode, const char* jsonStr)
{
OPUserType type = OPGameSDK::GetInstance().mShareType;
if (type == kFBShare) {
cout<<"facebook分享链接"<<endl;
}else if(type == kFBShareImage){
cout<<"facebook分享图片"<<endl;
}else if(type == kFBInviteFriend){
cout<<"facebook邀请"<<endl;
}
if (errorCode == 1) {
OPSDK::GetInstance().ShowMsg("分享成功");
}else if (errorCode == 0){
OPSDK::GetInstance().ShowMsg("取消分享");
}else{
OPSDK::GetInstance().ShowMsg("分享失败");
}
}
在Info.plist文件中设置Facebook好友权限
<key>Ourpalm_facebook_friends</key>
<false/>
注意:默认设置为支持好友权限;true:需要邀请好友权限;false:无需邀请好友权限
void OPSDK::inviteFriend()
{
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//邀请好友
Json::Value shareJson;
shareJson["title"] = Json::Value("title");//标题
shareJson["message"] = Json::Value("message");//消息
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBInviteFriend);
}
回调数据格式:
{
request = 1501199046846374;
to = (
364167064041191 //FB好友的用户id
);
"to[0]" = 364167064041191; //FB好友的用户id
}
void OPSDK::shareLink()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
Json::Value shareJson;
shareJson["link"] = Json::Value("https://developers.facebook.com/docs/ios/share/");
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShare);
}
void OPSDK::shareImage()
{
//设置分享回调
OPGameSDK::GetInstance().ShareCallBack(fbShareCallback);
//分享
Json::Value shareJson;
//网络图片
//shareJson["picture"] = Json::Value("http://content.game-bean.com/image/98kof/pc/pc_banner01.jpg");
//本地图片
NSString *filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"localPic.png"];
shareJson["picture"] = Json::Value([filePath UTF8String]);
Json::FastWriter fast_writer;
string shareStr = fast_writer.write(shareJson);
OPGameSDK::GetInstance().ShareToThirdPlatform(shareStr.c_str(),kFBShareImage);
}