Skip to content

RajeevRShephertz/App42_Cocos2dX_SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

App42_Cocos2dX_SDK

Migration Note:-

The way of providing response callback in every API is changed in this release

Please follow the steps mentioned below for migrating your build from previous version to this version:

Previous Version Code Snippet for .h file

//TestPushNotificationService.h

class TestPushNotificationService : public cocos2d::Layer
{
   void onPushRequestCompleted(cocos2d::Node *sender, void *response)
};

New Version Code Snippet .h file

//TestPushNotificationService.h
#include "App42API.h"

// Your Callback Class must inherit App42CallBack in order to define callbacks
class TestPushNotificationService : public cocos2d::Layer, public App42CallBack
{
   void registerDeviceToken(Ref *sender);
   
   //Callback method declaration
   void onPushRequestCompleted(App42CallBack *sender, void *response);
};

Previous Version Code Snippet for .cpp file

//TestPushNotificationService.cpp

void TestPushNotificationService::registerDeviceToken(Ref *sender)
{
    //Calling PushNotification service API
    PushNotificationService *pushService = App42API::BuildPushNotificationService();
    pushService->registerDeviceToken(deviceToken, userName, deviceType, this, callfuncND_selector(HelloWorld::onPushRequestCompleted));
}

void TestPushNotificationService::onPushRequestCompleted(cocos2d::Node *sender, void *response)
{
    App42PushNotificationResponse *pushResponse = (App42PushNotificationResponse*)response;
    printf("\ncode=%d",pushResponse->getCode());
    printf("\nResponse Body=%s",pushResponse->getBody().c_str());
    if (!pushResponse->isSuccess)
    {
        printf("\nerrordetails:%s",pushResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",pushResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",pushResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",pushResponse->httpErrorCode);
    }
    else
    {
        for(std::vector<App42PushNotification>::iterator it = pushResponse->notification.begin(); it != pushResponse->notification.end(); ++it)
        {
            printf("\n UserName=%s",it->userName.c_str());
            printf("\n Message=%s\n",it->message.c_str());
        }
    }
}

New Version Code Snippet .cpp file

//TestPushNotificationService.cpp

void TestPushNotificationService::registerDeviceToken(Ref *sender)
{
	//Calling PushNotification service API
    PushNotificationService *pushService = App42API::BuildPushNotificationService();
    pushService->RegisterDeviceToken(deviceToken, userName, IOS, this, app42callfuncND_selector(TestPushNotificationService::onPushRequestCompleted));
}

//Callback method definition
void TestPushNotificationService::onPushRequestCompleted(App42CallBack *sender, void *response)
{
    App42PushNotificationResponse *pushResponse = (App42PushNotificationResponse*)response;
    printf("\ncode=%d",pushResponse->getCode());
    printf("\nResponse Body=%s",pushResponse->getBody().c_str());
    if (!pushResponse->isSuccess)
    {
        printf("\nerrordetails:%s",pushResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",pushResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",pushResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",pushResponse->httpErrorCode);
    }
    else
    {
        for(std::vector<App42PushNotification>::iterator it = pushResponse->notifications.begin(); it != pushResponse->notifications.end(); ++it)
        {
            printf("\n UserName=%s",it->userName.c_str());
            printf("\n Message=%s\n",it->message.c_str());
            
            for(std::vector<App42Channel>::iterator channel = it->channelArray.begin(); channel != it->channelArray.end(); ++channel)
            {
                printf("\n Channel Name=%s",channel->channelName.c_str());
                printf("\n Description=%s\n",channel->description.c_str());
            }
        }
    }
}

To know more you can go through the Tests

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published