Use of SDKBOX::Plugin for Facebook ask a friend for life

Any one here has an idea about how to implement ask a friend in cocos2dx.
Where one user ask a life from his friend and if friend accepts his request then requested user gets his life filled.

u will need your own backend server, facebook will be used just to retrieve user ID and friend ID. So u storing for example in database info like date, user_sent_id , user_receive_id, gift_type , gift_collected flag. Then making requests to your backend thru http from app for example you can set response in json format and so on…

Hello Energy, Thanks for the suggestion but i heard that using Facebook we can create object which can be used for ask a life and for gift as well without using any backend server.

Here is the link that i came across - https://developers.facebook.com/docs/games/services/gamerequests

Yes, this is entirely possible from the Facebook SDK - you can ask for something or send something using these app requests, but currently it seems that this functionality isn’t present in the SDKBOX plugin.

Would like to know if it is on the roadmap as it doesn’t seem to require much tinkering, since the friend invite dialog is here and this uses the same functions on both iOS and Android, only you have to specify the action type and object id. It would be even better if this is a thin wrapper on top of the Facebook SDK as it would require less code and offer all the functionality from the SDK.

I am planning to develop my games for mobile and web using JS, so it came as a bummer to me that my manual web wrapper can send app requests, but if a person is using the native app, he/she can’t access them.

Yes, there is plan for support game requests, currently we’re focusing on creating plugin for Cocos Creator, It will probably happen after that.

Ok, nice :slight_smile:

Without trying to put any pressure on you, can you give an estimate on when it might happen (any possibility for getting this within a month or two) ?

Likely later February 2017

Thank you for the information :slight_smile:

Hello Guys, Any update Regarding Facebook Ask a Friend…

Yes, there is a new API requestGift for it.

Is this new functionality available in the plugin as I can’t find anything about it in the documentation? Also I hope that there is a corresponding function for sending a gift :slight_smile:

I saw from the plugin’s download page http://www.sdkbox.com/plugins/facebookhttp://www.sdkbox.com/plugins/facebook that version 2.3.11 went live today and from the code I see the requestGift function.

Since a sendGift function would be needed as well to complete this functionality maybe you could merge the 2 functions together and offer more versatility to the developers by adding some additional parameters like the window title and additional data for the request. You could also just have the shared function as a backend and use it to make the send/request gift functions more easy.

This is what I have in my project for the web version of it (since SDKBOX’s Facebook plugin doesn’t support web)

FriendObjectRequest: function(request_type, title, message, object_id, additional_data, friendIds) {

    var params = {};

    if (friendIds) {
        params['to'] = friendIds.join(', ');
    }

    if (title != '') {
        params['title'] = title;
    }

    if (additional_data != '') {
        params['data'] = additional_data;
    }

    params['message'] = message;
    params['action_type'] = request_type;
    params['object_id'] = object_id;
    
    facebook.appRequest(params, function(code, data) {
        // callback
    });

}

And then I have these 2 helper functions that are just for making the arguments less:

RequestObject: function(title, message, object_id, additional_data, friendIds) {
    this.FriendObjectRequest('askfor', title, message, object_id, additional_data, friendIds);
}

SendObject: function(title, message, object_id, additional_data, friendIds) {
    this.FriendObjectRequest('send', title, message, object_id, additional_data, friendIds);
}

Even if you just merge the send and request logic into 1 function with the request_type as a parameter I think that you will give more functionality to the developers and you will have to write less code for it.

1 Like