Search
Duplicate

Pop-up (Optional)

생성일
2024/03/14 06:50
태그
The PC SDK provides APIs to integrate popups into your game. Pop-ups supported by PC SDK include automatic, manual, news, coupon, and community.
The PC SDK provides data for popups to the game. The game creates a pop-up view using the provided data.
Each popup is defined as follows.
Automatic pop-up: Pop-up that is most exposed on the game lobby screen and shows advertisements and events
Manual pop-up: Pop-up showing registered events corresponding to the resource key -News pop-up: A pop-up that collects and shows announcement posts at once
Coupon pop-up: Pop-up showing the coupon registration page
Community popup: Popup showing the game community page
In order to use the PC SDK popup API, the metadata registration of the popup integrated with Partners must be preceded.

1. Callback setting

To communicate with the PC SDK using the pop-up API, the game must define a callback function to connect to the callback pointer of the StovePCCallback structure below.
struct StovePCCallback { void(*OnError)(const StovePCError error); void(*OnInitComplete)(); void(*OnToken)(const StovePCToken token); void(*OnUser)(const StovePCUser user); void(*OnOwnership)(int size, StovePCOwnership* ownership); /// Callback called when GetAutoPopup processing is complete void(*OnAutoPopup)(int size, StovePCAutoPopup* autoPopup, int headerSize, StovePCPopupRequestHeader* header); /// Callback called when GetManualPopup processing is complete void(*OnManualPopup)(int size, StovePCManualPopup* manualPopup, int headerSize, StovePCPopupRequestHeader* header); /// Callback called when GetNewsPopup processing is complete void(*OnNewsPopup)(StovePCNewsPopup newsPopup, int headerSize, StovePCPopupRequestHeader* header); /// Callback called when GetCouponPopup processing is complete void(*OnCouponPopup)(StovePCCouponPopup couponPopup, int headerSize, StovePCPopupRequestHeader* header); /// Callback called when GetCommunityPopup processing is complete void(*OnCommunityPopup)(StovePCCommunityPopup communityPopup, int cookieSize, StovePCPopupRequestCookie* cookie); };
C++
복사
Connect the callback function to the callback pointer of the StovePCCallback structure as in Config, Callbak setting.
// Create StovePCCallback structure instance StovePCCallback callback; // Initialize all function pointers to NULL memset(&callback, 0, sizeof(StovePCCallback)); // Link implemented function pointers callback.OnError = OnMyErrorCallback; /* Callback function defined globally */ callback.OnInitComplete = OnMyInitCompleteCallback; /* Callback function defined globally */ callback.OnToken = OnMyTokenCallback; /* Callback function defined globally */ callback.OnUser = OnMyUserInfoCallback; /* Callback function defined globally */ callback.OnOwnership = OnMyOwnershipCallback; /* Callback function defined globally */ // pop-up callback.OnAutoPopup = OnMyAutoPopup; /* Callback function defined globally */ callback.OnManualPopup = OnMyManualPopup; /* Callback function defined globally */ callback.OnNewsPopup = OnMyNewsPopup; /* Callback function defined globally */ callback.OnCouponPopup = OnMyCouponPopup; /* Callback function defined globally */ callback.OnCommunityPopup = OnMyCommunityPopup; /*Callback function defined globally*
C++
복사
You are not required to implement the OnAutoPopupOnManualPopupOnNewsPopupOnCouponPopupOnCommunityPopup callbacks.
All you need to do is implement and connect only the callback function that is necessary for the popup used in the game.

2. Game profile settings

Set game world and character information with StovePC_SetGameProfile function.
Set information is used in pop-ups, so it must be set before using pop-ups.
The validity of the game profile is not checked separately. Therefore, you must enter the correct value by proceeding with validation (null) when entering.
The entered game profile is only valid for the life cycle of PCSDK.
That is, whenever PCSDK is initialized, the StovePC_SetGameProfile function must be called to set the game world and character information.
// input parameters // const char* worldId: the world identifier of the game // const long characterNo: character identifier StovePCResult result = StovePC_SetGameProfile("WORLD_ID", CHARACTER_NO); if(result == StovePCResult::STOVE_PC_NO_ERROR) { /* handle success */ }
C++
복사

3. Get automatic pop-up information

Search information about auto popup with StovePC_GetAutoPopup function.
StovePCResult result = StovePC_GetAutoPopup(); if(result == StovePCResult::STOVE_PC_NO_ERROR) { /* handle success */ }
C++
복사
When the StovePC_GetAutoPopup function is successfully processed, the OnAutoPopup callback is called.
The StovePCAutoPopup structure passed to the callback contains the URL to the auto-popup.
The StovePCPopupRequestHeader structure passed to the callback contains name/value pairs of headers to be set when requesting URLs.
void OnAutoPopup(int size, StovePCAutoPopup* autoPopup, int headerSize, StovePCPopupRequestHeader* header) { printf("OnAutoPopup"); printf(" - autoPopup size = %d", size); for (int i = 0; i < size; i++, autoPopup++) { printf("- autoPopup[%d].origin : %s", i, autoPopup->origin); printf("- autoPopup[%d].id : %d", i, autoPopup->id); printf("- autoPopup[%d].url : %s", i, autoPopup->url); // ADD 2.6.0 Start printf("- autoPopup[%d].control.ui.visible.closeButton : %s", i, autoPopup->control.ui.visible.closeButton ? "true" : "false"); printf("- autoPopup[%d].control.ui.visible.navigationBar : %s", i, autoPopup->control.ui.visible.navigationBar ? "true" : "false"); printf("- autoPopup[%d].control.ui.visible.backButton : %s", i, autoPopup->control.ui.visible.backButton ? "true" : "false"); printf("- autoPopup[%d].control.ui.visible.forwardButton : %s", i, autoPopup->control.ui.visible.forwardButton ? "true" : "false"); printf("- autoPopup[%d].control.ui.visible.refreshButton : %s", i, autoPopup->control.ui.visible.refreshButton ? "true" : "false"); printf("- autoPopup[%d].control.ui.visible.homeButton : %s", i, autoPopup->control.ui.visible.homeButton ? "true" : "false"); printf("- autoPopup[%d].control.ui.visible.disallowedButton : %s", i, autoPopup->control.ui.visible.disallowedButton ? "true" : "false"); printf("- autoPopup[%d].control.ui.disallowedDay : %d", i, autoPopup->control.ui.disallowedDay); printf("- autoPopup[%d].control.ui.closeButtonImage.normal.fileUrl : %s", i, autoPopup->control.ui.closeButtonImage.normal.fileUrl); printf("- autoPopup[%d].control.ui.closeButtonImage.normal.fileId : %s", i, autoPopup->control.ui.closeButtonImage.normal.fileId); printf("- autoPopup[%d].control.ui.closeButtonImage.pressed.fileUrl : %s", i, autoPopup->control.ui.closeButtonImage.pressed.fileUrl); printf("- autoPopup[%d].control.ui.closeButtonImage.pressed.fileId : %s", i, autoPopup->control.ui.closeButtonImage.pressed.fileId); printf("- autoPopup[%d].control.ui.closeButtonImage.type : %d", i, autoPopup->control.ui.closeButtonImage.type); printf("---------------------------------------------- --"); // 2.6.0 End } printf("header size = %d", headerSize); for (int i = 0; i < headerSize; i++, header++) { printf(" -> index: %d", i); printf("name : %s", header->name); printf("value : %s", header->value); printf("---------------------------------------------- --"); } }
C++
복사
Precautions The valid scope of the callback parameter StovePCAutoPopup/StovePCPopupRequestHeader structure is limited to the scope of the callback function. PC SDK frees internally allocated memory as soon as callback function execution is completed. Therefore, if you need to save the information of StovePCAutoPopup/StovePCPopupRequestHeader structure outside the scope of the callback function, make sure to create a copy through deep copy, When the use of the copy is complete, the memory must be freed.
Even if the success callback (OnAutoPopup) is executed, the size callback parameter may be 0.
At this time, null is passed to the autoPopup callback parameter. Before using the autoPopup callback parameter, you should check the size callback parameter before deciding whether or not to open a popup.
In this case, check the automatic pop-up settings of Partners.
The display order of auto popup must be the same as the order of autoPopup array elements. For example, if your autoPopup array contains three elements [A,B,C], you should expose popups in A, B, C order.
If an error occurs while running the StovePC_GetAutoPopup function, the OnError callback is called.
External errors can be checked through the ExternalError field of the StovePCError structure.
ExternalError
Description
403000
Invalid Access Error
400000
Wrong API usage Error
400001
Not Found Error
400002
Not Match Error
400003
Already exist
500001
Internal Interaction Error
900000
Unknown Service Error

4. Obtain manual pop-up information

Search information about manual popup with StovePC_GetManualPopup function.
// input parameters // string resourceKey: Manual pop-up identifier registered by Partners StovePCResult result = StovePC_GetManualPopup("RESOURCE_KEY"); if(result == StovePCResult::STOVE_PC_NO_ERROR) { /* handle success */ }
C++
복사
When the StovePC_GetManualPopup function is successfully processed, the OnManualPopup callback is called.
The StovePCManualPopup structure passed to the callback contains the URL to the manual popup.
The StovePCPopupRequestHeader structure passed to the callback contains name/value pairs of headers to be set when requesting URLs.
void OnManualPopup(int size, StovePCManualPopup* manualPopup, int headerSize, StovePCPopupRequestHeader* header) { printf("OnManualPopup"); printf(" - manualPopup size = %d", size); for (int i = 0; i < size; i++, manualPopup++) { printf("- manualPopup[%d].origin : %s", i, autoPopup->origin); printf("- manualPopup[%d].id : %d", i, autoPopup->id); printf("- manualPopup[%d].url : %s", i, autoPopup->url); // ADD 2.6.0 Start printf("- manualPopup[%d].control.ui.visible.closeButton : %s", i, manualPopup->control.ui.visible.closeButton ? "true" : "false"); printf("- manualPopup[%d].control.ui.visible.navigationBar : %s", i, manualPopup->control.ui.visible.navigationBar ? "true" : "false"); printf("- manualPopup[%d].control.ui.visible.backButton : %s", i, manualPopup->control.ui.visible.backButton ? "true" : "false"); printf("- manualPopup[%d].control.ui.visible.forwardButton : %s", i, manualPopup->control.ui.visible.forwardButton ? "true" : "false"); printf("- manualPopup[%d].control.ui.visible.refreshButton : %s", i, manualPopup->control.ui.visible.refreshButton ? "true" : "false"); printf("- manualPopup[%d].control.ui.visible.homeButton : %s", i, manualPopup->control.ui.visible.homeButton ? "true" : "false"); printf("- manualPopup[%d].control.ui.visible.disallowedButton : %s", i, manualPopup->control.ui.visible.disallowedButton ? "true" : "false"); printf("- manualPopup[%d].control.ui.disallowedDay : %d", i, manualPopup->control.ui.disallowedDay); printf("- manualPopup[%d].control.ui.closeButtonImage.normal.fileUrl : %s", i, manualPopup->control.ui.closeButtonImage.normal.fileUrl); printf("- manualPopup[%d].control.ui.closeButtonImage.normal.fileId : %s", i, manualPopup->control.ui.closeButtonImage.normal.fileId); printf("- manualPopup[%d].control.ui.closeButtonImage.pressed.fileUrl : %s", i, manualPopup->control.ui.closeButtonImage.pressed.fileUrl); printf("- manualPopup[%d].control.ui.closeButtonImage.pressed.fileId : %s", i, manualPopup->control.ui.closeButtonImage.pressed.fileId); printf("- manualPopup[%d].control.ui.closeButtonImage.type : %d", i, manualPopup->control.ui.closeButtonImage.type); printf("---------------------------------------------- --"); // 2.6.0 End } printf("header size = %d", headerSize); for (int i = 0; i < headerSize; i++, header++) { printf(" -> index: %d", i); printf("name : %s", header->name); printf("value : %s", header->value); printf("---------------------------------------------- --"); } }
C++
복사
Precautions The valid scope of the callback parameter StovePCManualPopup/StovePCPopupRequestHeader structure is limited to the scope of the callback function. PC SDK frees internally allocated memory as soon as callback function execution is completed. Therefore, if you need to save the information of StovePCManualPopup/StovePCPopupRequestHeader structure outside the scope of the callback function, make sure to create a copy through deep copy, When the use of the copy is complete, the memory must be freed. Even if the success callback (OnManualPopup) is executed, the size callback parameter may be 0. At this time, null is passed to the manualPopup callback parameter. Before using the manualPopup callback parameter, you should check the size callback parameter first and decide whether or not to open a popup. In this case, check the manual pop-up settings of Partners. The display order of manual popup must be the same as the order of manualPopup array elements. For example, if the manualPopup array contains three elements [A,B,C], then we need to expose popups in A, B, C order.
If an error occurs while executing StovePC_GetManualPopup function, OnError callback is called.
External errors can be checked through the ExternalError field of the StovePCError structure.
ExternalError
Description
403000
Invalid Access Error
400000
Wrong API usage Error
400001
Not Found Error
400002
Not Match Error
400003
Already exist
500001
Internal Interaction Error
900000
Unknown Service Error

5. Get news pop-up information

Search information about news popup with StovePC_GetNewsPopup function.
StovePCResult result = StovePC_GetNewsPopup(); if(result == StovePCResult::STOVE_PC_NO_ERROR) { /* handle success */ }
C++
복사
When the StovePC_GetNewsPopup function is successfully processed, the OnNewsPopup callback is called.
The StovePCNewsPopup structure passed to the callback contains the URL to the newspopup.
The StovePCPopupRequestHeader structure passed to the callback contains name/value pairs of headers to be set when requesting URLs.
void OnNewsPopup(StovePCNewsPopup newsPopup, int headerSize, StovePCPopupRequestHeader* header) { printf("OnNewsPopup"); printf("- newsPopup.origin : %s", i, autoPopup->origin); printf("- newsPopup.id : %d", i, autoPopup->id); printf("- newsPopup.url : %s", i, autoPopup->url); // ADD 2.6.0 Start printf("- newsPopup.control.ui.visible.closeButton : %s", newsPopup.control.ui.visible.closeButton ? "true" : "false"); printf("- newsPopup.control.ui.visible.navigationBar : %s", newsPopup.control.ui.visible.navigationBar ? "true" : "false"); printf("- newsPopup.control.ui.visible.backButton : %s", newsPopup.control.ui.visible.backButton ? "true" : "false"); printf("- newsPopup.control.ui.visible.forwardButton : %s", newsPopup.control.ui.visible.forwardButton ? "true" : "false"); printf("- newsPopup.control.ui.visible.refreshButton : %s", newsPopup.control.ui.visible.refreshButton ? "true" : "false"); printf("- newsPopup.control.ui.visible.homeButton : %s", newsPopup.control.ui.visible.homeButton ? "true" : "false"); printf("- newsPopup.control.ui.visible.disallowedButton : %s", newsPopup.control.ui.visible.disallowedButton ? "true" : "false"); printf("- newsPopup.control.ui.disallowedDay : %d", newsPopup.control.ui.disallowedDay); printf("- newsPopup.control.ui.closeButtonImage.normal.fileUrl : %s", newsPopup.control.ui.closeButtonImage.normal.fileUrl); printf("- newsPopup.control.ui.closeButtonImage.normal.fileId : %s", newsPopup.control.ui.closeButtonImage.normal.fileId); printf("- newsPopup.control.ui.closeButtonImage.pressed.fileUrl : %s", newsPopup.control.ui.closeButtonImage.pressed.fileUrl); printf("- newsPopup.control.ui.closeButtonImage.pressed.fileId : %s", newsPopup.control.ui.closeButtonImage.pressed.fileId); printf("- newsPopup.control.ui.closeButtonImage.type : %d", newsPopup.control.ui.closeButtonImage.type); printf("header size = %d", headerSize); // 2.6.0 End for (int i = 0; i < headerSize; i++, header++) { printf(" -> index: %d", i); printf("name : %s", header->name); printf("value : %s", header->value); printf("---------------------------------------------- --"); } }
C++
복사
Precautions The valid scope of the callback parameter StovePCNewsPopup/StovePCPopupRequestHeader structure is limited to the scope of the callback function. PC SDK frees internally allocated memory as soon as callback function execution is completed. Therefore, if you need to save the information of StovePCNewsPopup/StovePCPopupRequestHeader structure outside the scope of the callback function, you must create a copy through deep copy. When the use of the copy is complete, the memory must be freed. Even if the success callback (OnNewsPopup) is executed, newsPopup callback parameter properties may be default values (empty string or 0). After checking the url property of the newsPopup callback parameter, you should decide whether to open a popup or not. In this case, check the news pop-up settings of Partners. If an error occurs while running the StovePC_GetNewsPopup function, the OnError callback is called.
External errors can be checked through the ExternalError field of the StovePCError structure.
ExternalError
Description
403000
Invalid Access Error
400000
Wrong API usage Error
400001
Not Found Error
400002
Not Match Error
400003
Already exist
500001
Internal Interaction Error
900000
Unknown Service Error

6. Get coupon pop-up information

Search coupon popup information with StovePC_GetCouponPopup function.
StovePCResult result = StovePC_GetCouponPopup(); if(result == StovePCResult::STOVE_PC_NO_ERROR) { /* handle success */ }
C++
복사
When the StovePC_GetCouponPopup function is successfully processed, the OnCouponPopup callback is called.
The StovePCCouponPopup structure passed to the callback contains the URL to the coupon popup.
The StovePCPopupRequestHeader structure passed to the callback contains name/value pairs of headers to be set when requesting URLs.
void OnCouponPopup(StovePCCouponPopup couponPopup, int headerSize, StovePCPopupRequestHeader* header) { printf("OnCouponPopup"); printf("- couponPopup.origin: %s", i, couponPopup.origin); printf("- couponPopup.id : %d", i, couponPopup.id); printf("- couponPopup.url : %s", i, couponPopup.url); // ADD 2.6.0 Start printf("- couponPopup.control.ui.visible.closeButton : %s", couponPopup.control.ui.visible.closeButton ? "true" : "false"); printf("- couponPopup.control.ui.visible.navigationBar : %s", couponPopup.control.ui.visible.navigationBar ? "true" : "false"); printf("- couponPopup.control.ui.visible.backButton : %s", couponPopup.control.ui.visible.backButton ? "true" : "false"); printf("- couponPopup.control.ui.visible.forwardButton : %s", couponPopup.control.ui.visible.forwardButton ? "true" : "false"); printf("- couponPopup.control.ui.visible.refreshButton : %s", couponPopup.control.ui.visible.refreshButton ? "true" : "false"); printf("- couponPopup.control.ui.visible.homeButton : %s", couponPopup.control.ui.visible.homeButton ? "true" : "false"); printf("- couponPopup.control.ui.visible.disallowedButton : %s", couponPopup.control.ui.visible.disallowedButton ? "true" : "false"); printf("- couponPopup.control.ui.disallowedDay : %d", couponPopup.control.ui.disallowedDay); printf("- couponPopup.control.ui.closeButtonImage.normal.fileUrl : %s", couponPopup.control.ui.closeButtonImage.normal.fileUrl); printf("- couponPopup.control.ui.closeButtonImage.normal.fileId : %s", couponPopup.control.ui.closeButtonImage.normal.fileId); printf("- couponPopup.control.ui.closeButtonImage.pressed.fileUrl : %s", couponPopup.control.ui.closeButtonImage.pressed.fileUrl); printf("- couponPopup.control.ui.closeButtonImage.pressed.fileId : %s", couponPopup.control.ui.closeButtonImage.pressed.fileId); printf("- couponPopup.control.ui.closeButtonImage.type : %d", couponPopup.control.ui.closeButtonImage.type); printf("header size = %d", headerSize); // 2.6.0 End for (int i = 0; i < headerSize; i++, header++) { printf(" -> index: %d", i); printf("name : %s", header->name); printf("value : %s", header->value); printf("---------------------------------------------- --"); } }
C++
복사
Precautions The valid scope of the callback parameter StovePCCouponPopup/StovePCPopupRequestHeader structure is limited to the scope of the callback function. PC SDK frees internally allocated memory as soon as callback function execution is completed. Therefore, if you need to save the information of StovePCCouponPopup/StovePCPopupRequestHeader structure outside the scope of the callback function, you must create a copy through deep copy, and When the use of the copy is complete, the memory must be freed.
If an error occurs while running the StovePC_GetCouponPopup function, the OnError callback is called.

7. Get community pop-up information

Use the StovePC_GetCommunityPopup function to retrieve community popup information.
StovePCResult result = StovePC_GetCommunityPopup(); if(result == StovePCResult::STOVE_PC_NO_ERROR) { /* handle success */ }
C++
복사
When the StovePC_GetCommunityPopup function is successfully processed, the OnCommunityPopup callback is called.
The StovePCCommunityPopup structure passed to the callback contains the URL to the community popup.
The StovePCPopupRequestCookie structure passed to the callback contains the cookie name/value pair to be set when requesting the URL.
void OnCommunityPopup(StovePCCommunityPopup communityPopup, int cookieSize, StovePCPopupRequestCookie* cookie) { printf("OnCommunityPopup"); printf("- communityPopup.url : %s", i, couponPopup.url); // ADD 2.6.0 Start printf("- communityPopup.control.ui.visible.closeButton : %s", communityPopup.control.ui.visible.navigationBar ? "true" : "false"); printf("- communityPopup.control.ui.visible.navigationBar : %s", communityPopup.control.ui.visible.navigationBar ? "true" : "false"); printf("- communityPopup.control.ui.visible.backButton : %s", communityPopup.control.ui.visible.backButton ? "true" : "false"); printf("- communityPopup.control.ui.visible.forwardButton : %s", communityPopup.control.ui.visible.forwardButton ? "true" : "false"); printf("- communityPopup.control.ui.visible.refreshButton : %s", communityPopup.control.ui.visible.refreshButton ? "true" : "false"); printf("- communityPopup.control.ui.visible.homeButton : %s", communityPopup.control.ui.visible.homeButton ? "true" : "false"); printf("- communityPopup.control.ui.visible.disallowedButton : %s", communityPopup.control.ui.visible.disallowedButton ? "true" : "false"); printf("- communityPopup.control.ui.disallowedDay : %d", communityPopup.control.ui.disallowedDay); printf("- communityPopup.control.ui.closeButtonImage.normal.fileUrl : %s", communityPopup.control.ui.closeButtonImage.normal.fileUrl); printf("- communityPopup.control.ui.closeButtonImage.normal.fileId : %s", communityPopup.control.ui.closeButtonImage.normal.fileId); printf("- communityPopup.control.ui.closeButtonImage.pressed.fileUrl : %s", communityPopup.control.ui.closeButtonImage.pressed.fileUrl); printf("- communityPopup.control.ui.closeButtonImage.pressed.fileId : %s", communityPopup.control.ui.closeButtonImage.pressed.fileId); printf("- communityPopup.control.ui.closeButtonImage.type : %d", communityPopup.control.ui.closeButtonImage.type); printf("cookie size = %d", cookieSize); // 2.6.0 End for (int i = 0; i < headerSize; i++, cookies++) { printf(" -> index: %d", i); printf("name : %s", header->name); printf("value : %s", header->value); printf("---------------------------------------------- --"); } }
C++
복사
Precautions The valid scope of the callback parameter StovePCCommunityPopup/StovePCPopupRequestCookie structure is limited to the scope of the callback function. PC SDK frees internally allocated memory as son as callback function execution is completed. Therefore, if you need to save the information of StovePCcommunityPopup/StovePCPopupRequestCookie structure outside the scope of the callback function, make sure to create a copy through deep copy, When the use of the copy is complete, the memory must be freed.
If an error occurs while running the StovePC_GetCommunityPopup function, the OnError callback is called.
External errors can be checked through the ExternalError field of the StovePCError structure.
ExternalError
Description
13008
Mandatory Parameter missing
90001
AccessToken invalid
40101
Invalid token

8. Disable pop-ups

Use the StovePC_SetPopupDisallowed function to disable certain pop-ups from being displayed for a certain period of time.
If the game directly implements the PC SDK pop-up UI, configure the UI by referring to the control.ui.visible.disallowedButton value of the pop-up UI information.
Call StovePC_SetPopupDisallowed function from button click handler.
When calling the StevePC_SetPopupDisallowed method, the days parameter uses the value of control.UI.disallowedDay from the popup information.
If pop-up disallow is set, the relevant pop-up information will not be searched during the disallow period.
// input parameters // int popupId : Popup identifier issued by Partners // int days : the number of days of disallowance registered by Partners (once) or -1 (don't look again) // int days : Unacceptable period registered by Partners (in days) StovePCResult result = StovePC_SetPopupDisallowed(POPUP_ID, DAYS); if (result == StovePCResult::STOVE_PC_NO_ERROR) { // handle success }
C++
복사