@yinjimmy thanks for the answer.
Respect to the first point. My listener does not work.
In AppDelegate.cpp
(method applicationDidFinishLaunching
) I add this code:
#ifdef SDKBOX_ENABLED
sdkbox::PluginFacebook::setListener(FacebookHandler::getInstance());
sdkbox::PluginFacebook::init();
#endif
This is my FacebookHandler
class:
class FacebookHandler : public sdkbox::FacebookListener
{
public:
FacebookHandler();
~FacebookHandler();
static FacebookHandler* getInstance();
void onGetUserInfo(const sdkbox::FBGraphUser &userInfo);
};
Methods:
FacebookHandler::FacebookHandler()
{
}
FacebookHandler* FacebookHandler::getInstance()
{
static FacebookHandler *sharedInstance;
return sharedInstance;
}
void FacebookHandler::onGetUserInfo(const sdkbox::FBGraphUser &userInfo)
{
log("Facebook id:'%s' name:'%s' last_name:'%s' first_name:'%s' email:'%s' installed:'%d'",
userInfo.getUserId().c_str(),
userInfo.getName().c_str(),
userInfo.getFirstName().c_str(),
userInfo.getLastName().c_str(),
userInfo.getEmail().c_str(),
userInfo.isInstalled ? 1 : 0
);
}
FacebookHandler::~FacebookHandler()
{
}
However, when I log in to Facebook, the framework does not call automatically onGetUserInfo
. What is my problem?
I debugged it. This is the log when the compiler execute setListener method.
2017-09-14 19:36:03.725980-0300 MyCppGame-mobile[15478:5307448] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-09-14 19:36:03.728194-0300 MyCppGame-mobile[15478:5307448] [MC] Reading from public effective user settings.
After that, compile the init method and the follow code in AppDelegate. This is the log:
2017-09-14 19:37:10.427545-0300 MyCppGame-mobile[15478:5307448] FBSDKLog: FBSDKTimeSpentData Restore: {"lastSuspendTime":1505353777,"numInterruptions":2,"sessionID":"7CCE0CA7-97F7-4612-A14D-F887205B7646","secondsSpentInCurrentSession":3}
2017-09-14 19:37:10.429198-0300 MyCppGame-mobile[15478:5307448] FBSDKLog: FBSDKAppEvents: Recording event @ 1505428630: {
"_eventName" = "fb_mobile_deactivate_app";
"_logTime" = 1505353777;
"_session_id" = "7CCE0CA7-97F7-4612-A14D-F887205B7646";
"_ui" = "no_ui";
"_valueToSum" = 3;
"fb_mobile_app_interruptions" = 2;
"fb_mobile_launch_source" = Unclassified;
"fb_mobile_time_between_sessions" = "session_quanta_6";
}
2017-09-14 19:37:10.429998-0300 MyCppGame-mobile[15478:5307448] FBSDKLog: FBSDKAppEvents Persist: Read 0 event states. First state has 0 events
2017-09-14 19:37:10.430090-0300 MyCppGame-mobile[15478:5307448] FBSDKLog: FBSDKAppEvents Persist: Clearing
2017-09-14 19:37:10.431600-0300 MyCppGame-mobile[15478:5307448] FBSDKLog: FBSDKAppEvents: Recording event @ 1505428630: {
"_eventName" = "fb_mobile_activate_app";
"_logTime" = 1505428630;
"_session_id" = "10201322-4FD3-41B9-AFA2-259A29841BB1";
"_ui" = "no_ui";
"fb_mobile_launch_source" = Unclassified;
}
2017-09-14 19:37:10.433684-0300 MyCppGame-mobile[15478:5307448] #### ACTIVE
2017-09-14 19:37:10.438306-0300 MyCppGame-mobile[15478:5307448] cocos2d: surface size: 640x1136
2017-09-14 19:37:10.449221-0300 MyCppGame-mobile[15478:5307448] cocos2d: surface size: 640x1136
2017-09-14 19:37:11.029013-0300 MyCppGame-mobile[15478:5307448] FBSDKLog: FBSDKAppEvents: Flushed @ 1505428631, 2 events due to 'EagerlyFlushingEvent' - {
"advertiser_id" = "FEC1AFC1-A366-4B1B-BFDC-BC7514B5E0DF";
"advertiser_tracking_enabled" = 1;
"anon_id" = "XZE3203852-BCCC-4922-8832-64ABD2815B06";
"application_tracking_enabled" = 1;
event = "CUSTOM_APP_EVENTS";
extinfo = "[\"i2\",\"com.gamefromscratch.gamename18\",\"1.0\",\"\",\"10.3.3\",\"iPhone9,3\",\"es_US\",\"GMT-3\",\"Carrier\",320,568,\"2.00\",2,30,5,\"America\\/Buenos_Aires\"]";
"url_schemes" = "[\"fb2045915002286566\",\"powBox\"]";
}
Events: [
{
"event" : {
"fb_mobile_time_between_sessions" : "session_quanta_6",
"_eventName" : "fb_mobile_deactivate_app",
"fb_mobile_launch_source" : "Unclassified",
"_logTime" : 1505353777,
"_session_id" : "7CCE0CA7-97F7-4612-A14D-F887205B7646",
"fb_mobile_app_interruptions" : 2,
"_ui" : "no_ui",
"_valueToSum" : 3
},
"isImplicit" : false
},
{
"event" : {
"_ui" : "no_ui",
"_eventName" : "fb_mobile_activate_app",
"_logTime" : 1505428630,
"_session_id" : "10201322-4FD3-41B9-AFA2-259A29841BB1",
"fb_mobile_launch_source" : "Unclassified"
},
"isImplicit" : false
}
]
Flush Result : Success
Then, I log in to facebook in my Game
class.
Code:
sdkbox::PluginFacebook::logout();
if(sdkbox::PluginFacebook::isLoggedIn() == false)
sdkbox::PluginFacebook::requestReadPermissions({sdkbox::FB_PERM_READ_PUBLIC_PROFILE, sdkbox::FB_PERM_READ_USER_FRIENDS});
This is the log after log in:
2017-09-14 19:38:59.082357-0300 MyCppGame-mobile[15478:5307448] FBSDKLog: FBSDKAppEvents: Flushed @ 1505428739, 2 events due to 'Timer' - {
"advertiser_tracking_enabled" = 1;
"anon_id" = "XZE3203852-BCCC-4922-8832-64ABD2815B06";
"application_tracking_enabled" = 1;
event = "CUSTOM_APP_EVENTS";
extinfo = "[\"i2\",\"com.gamefromscratch.gamename18\",\"1.0\",\"\",\"10.3.3\",\"iPhone9,3\",\"es_US\",\"GMT-3\",\"Carrier\",320,568,\"2.00\",2,30,5,\"America\\/Buenos_Aires\"]";
"url_schemes" = "[\"fb2045915002286566\",\"powBox\"]";
}
Events: [
{
"event" : {
"4_error_code" : "",
"_implicitlyLogged" : "1",
"7_logging_token" : "",
"_eventName" : "fb_mobile_login_start",
"_logTime" : 1505428735,
"1_timestamp_ms" : 1505428734833,
"6_extras" : "{\"default_audience\":\"friends\",\"tryIntegratedAuth\":false,\"tryFBAppAuth\":true,\"login_behavior\":\"FBSDKLoginBehaviorNative\",\"tryFallback\":false,\"permissions\":\"public_profile,user_friends\",\"trySafariAuth\":true,\"isReauthorize\":false}",
"_ui" : "no_ui",
"5_error_message" : "",
"2_result" : "",
"0_auth_logger_id" : "59EBB84A-1C45-427E-AE64-B20D474CA88E"
},
"isImplicit" : true
},
{
"event" : {
"0_auth_logger_id" : "59EBB84A-1C45-427E-AE64-B20D474CA88E",
"3_method" : "sfvc_auth",
"1_timestamp_ms" : 1505428734973,
"_ui" : "FBSDKContainerViewController",
"7_logging_token" : "",
"_logTime" : 1505428735,
"4_error_code" : "",
"_implicitlyLogged" : "1",
"6_extras" : "{\"isMessengerAppCanOpenURLSchemeRegistered\":false,\"isURLSchemeRegistered\":true,\"isFacebookAppCanOpenURLSchemeRegistered\":true}",
"2_result" : "",
"_eventName" : "fb_mobile_login_method_start",
"5_error_message" : ""
},
"isImplicit" : true
}
]
Flush Result : Success
017-09-14 19:39:28.119596-0300 MyCppGame-mobile[15478:5307448] FBSDKLog: FBSDKTimeSpentData Restore: {"lastSuspendTime":1505428759,"numInterruptions":0,"sessionID":"10201322-4FD3-41B9-AFA2-259A29841BB1","secondsSpentInCurrentSession":129}
2017-09-14 19:39:28.120139-0300 MyCppGame-mobile[15478:5307448] #### ACTIVE
2017-09-14 19:39:28.688460-0300 MyCppGame-mobile[15478:5307448] FBSDKLog: The app tried to call version v2.8. This app can only call versions v2.10 and higher, so the request defaulted to version v2.10. Link: https://developers.facebook.com/docs/apps/versions/
2017-09-14 19:39:28.688514-0300 MyCppGame-mobile[15478:5307448] FBSDKLog: The field 'email' is only accessible on the User object after the user grants the 'email' permission.
2017-09-14 19:39:41.084331-0300 MyCppGame-mobile[15478:5307448] FBSDKLog: FBSDKAppEvents: Flushed @ 1505428780, 2 events due to 'Timer' - {
"advertiser_tracking_enabled" = 1;
"anon_id" = "XZE3203852-BCCC-4922-8832-64ABD2815B06";
"application_tracking_enabled" = 1;
event = "CUSTOM_APP_EVENTS";
extinfo = "[\"i2\",\"com.gamefromscratch.gamename18\",\"1.0\",\"\",\"10.3.3\",\"iPhone9,3\",\"es_US\",\"GMT-3\",\"Carrier\",320,568,\"2.00\",2,30,5,\"America\\/Buenos_Aires\"]";
"url_schemes" = "[\"fb2045915002286566\",\"powBox\"]";
}
Events: [
{
"event" : {
"0_auth_logger_id" : "59EBB84A-1C45-427E-AE64-B20D474CA88E",
"3_method" : "sfvc_auth",
"1_timestamp_ms" : 1505428767706,
"_ui" : "no_ui",
"7_logging_token" : "",
"_logTime" : 1505428768,
"4_error_code" : "",
"_implicitlyLogged" : "1",
"6_extras" : "{}",
"2_result" : "success",
"_eventName" : "fb_mobile_login_method_complete",
"5_error_message" : ""
},
"isImplicit" : true
},
{
"event" : {
"0_auth_logger_id" : "59EBB84A-1C45-427E-AE64-B20D474CA88E",
"3_method" : "sfvc_auth",
"1_timestamp_ms" : 1505428767707,
"_ui" : "no_ui",
"7_logging_token" : "",
"_logTime" : 1505428768,
"4_error_code" : "",
"_implicitlyLogged" : "1",
"6_extras" : "{}",
"2_result" : "success",
"_eventName" : "fb_mobile_login_complete",
"5_error_message" : ""
},
"isImplicit" : true
}
]
Flush Result : Success
However, the method onGetUserInfo
is never called.
**
Respect to the second point.
The sdkbox team plans to add Like button? Despite of not have it, how can I add it? is there an easy way to implement the code here? https://developers.facebook.com/docs/sharing/ios/like-button/
Respect to the last point. This is the log:
2017-09-14 20:05:29.603077-0300 MyCppGame-mobile[15494:5311066] FBSDKLog: FBSDKAppEvents: Flushed @ 1505430329, 1 events due to 'Timer' - {
"advertiser_tracking_enabled" = 1;
"anon_id" = "XZE3203852-BCCC-4922-8832-64ABD2815B06";
"application_tracking_enabled" = 1;
event = "CUSTOM_APP_EVENTS";
extinfo = "[\"i2\",\"com.gamefromscratch.gamename18\",\"1.0\",\"\",\"10.3.3\",\"iPhone9,3\",\"es_US\",\"GMT-3\",\"Carrier\",320,568,\"2.00\",2,30,5,\"America\\/Buenos_Aires\"]";
"url_schemes" = "[\"fb2045915002286566\",\"powBox\"]";
}
Events: [
{
"event" : {
"_eventName" : "fb_app_invite_share_show",
"_logTime" : 1505430329,
"_implicitlyLogged" : "1",
"_ui" : "no_ui"
},
"isImplicit" : true
}
]
Flush Result : Success
.
.
.
.
ACS031006] View controller already tracked. Class, ID: FBSDKContainerViewController, 3088785018862332402
2017-09-14 20:07:10.273975-0300 MyCppGame-mobile[15494:5311231] [Firebase/Analytics][I-ACS031006] View controller already tracked. Class, ID: FBSDKContainerViewController, 3088785018862332402
2017-09-14 20:07:10.274 MyCppGame-mobile[15494] <Debug> [Firebase/Analytics][I-ACS031006] View controller already tracked. Class, ID: FBSDKContainerViewController, 3088785018862332402
2017-09-14 20:07:10.274155-0300 MyCppGame-mobile[15494:5311231] [Firebase/Analytics][I-ACS031006] View controller already tracked. Class, ID: FBSDKContainerViewController, 3088785018862332402
2017-09-14 20:07:10.274 MyCppGame-mobile[15494] <Debug> [Firebase/Analytics][I-ACS031006] View controller already tracked. Class, ID: FBSDKContainerViewController, 3088785018862332402
MyCppGame-mobile was compiled with optimization - stepping may behave oddly; variables may not be available.
It crashes in an assembler instruction.