iOS

Quick Start

Download the Latest Version

1. Sample Project Configuration

Sample/NNG SDK Sample

The folder that contains the sample project for Xcode

sample/NNG SDK Sample/Libraries

The folder that contains the SDK library file for iOS

README.md

Read me file

CHANGELOG.md

The file that elaborates on the major changes that had been implemented in each version

2. Configuration Setting

Naver Game iOS SDK supports iOS versions 12.0 and above.

Set the development environment as shown in the following in XCode in order to use NaverGame SDK.

  • Select the app that is going to be run amongst the TARGETS category. (NNG SDK Sample target with respect to the sample project)

  • Select the Build Setting tab and find Other Linker Flags from the Linking category.

    • If in either Basic or Customized modes, the Other Linker Flag might not appear, and in this case select All mode.

    • It can be easily found by entering Other Linker Flag into the search bar located in the upper right corner.

  • Add the -ObjC option and the -lc++ option to Other Linker Flags.

  • Add the following option to obtain user permission to Info.plist.

    • Privacy - Camera Usage Description

    • Privacy - Photo Library Usage Description

  • Select the app that is going to be run amongst the TARGETS category, and input the Identifier values and URL Schemes values into the URL Types category of the Info tab.

  • The Identifier value can be checked from the General tab of the relevant TARGET.

  • For the URL Schemes value , input the URL Scheme value that was used to register for the application in the developers center after logging in with a Naver Id.

  • Add the following two frameworks in the General Tab of App TARGET. NaverLogin framework is located in the Library folder under sample project.

    • NaverLogin.framework

    • SafariService.framework

3. initialize

  • Register the client Id, client secret, and the Id of the lounge that had been established, that was received after registering the application in the developers center after logging in with a Naver Id to NNGSDKManager.

  • Select the parent view controller that Naver Game SDK’s view will go on.

    [NNGSDKManager.shared setClientId:@"UKvNABLDsyEJusJGsXL2"
                         clientSecret:@"rK4suc_Qd0"
                             loungeId:@"naver_game_4developer"];
                             
    [NNGSDKManager.shared setParentViewController:self];

NNGSDKManager Class NNGSDKManager class is a class that controls the Naver Game SDK. Refer to the following content for detailed information on functionalities that could be managed with the NNGSDKManager class.

  • For processing after NAVER Login, add the following code to AppDelegate’s application:openURL:options: method.

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {

    // ... Some codes ...
    
    return [NNGSDKManager.shared handleCallbackUrl:url];
}

Start Naver Game SDK

1. countryCode Property

The countryCode Property is the country code (ISO 3166-1 alpha-2) composed of two alphabets. This enables branch processing by countries within the codes. The notable country codes are as shown in the following. Refer to the link for other country codes.

Country Code

Country

CN

China

JP

Japan

KR

Republic of Korea

TH

Thailand

US

United States of America

2. canWriteFeedByScreenshot Property

This gives the option to show a writing shortcut when a user captures their screen.

Writing shortcuts is shown below.

3. registerMemberGameId: Method

This is a method for registering Game ID to sync NAVER ID and Game ID. The following is an example of registerMemberGameId: Method.

[NNGSDKManager.shared registerMemberGameId:@"gameId123"];

4.presentBannerViewController: method

presentBannerViewController: method used to show the banner screen. The following case is a demonstration of the implementation of the presentBannerViewController:

[NNGSDKManager.shared presentBannerViewController];

5. presentSorryViewController: method

presentSorryViewController: method used to show the emergency notification screen. In the case of a game API communication failure, it is recommended that this method be used to hide or deactivate the other UIs that serves as the entrance point for the SDK in order to inhibit the user from using the SDK. The following case is a demonstration of the implementation of the presentSorryViewController:

[NNGSDKManager.shared presentSorryViewController];

6. presentBoardViewControllerWith: method

presentBoardViewControllerWith: method used to show the bulletin board. Takes the bulletin board ID created after selecting the bulletin board from the management page as the parameter. The following case is a demonstration of the implementation of the presentBoardViewControllerWith:

[NNGSDKManager.shared presentBoardViewControllerWith:@1];

The Board ID value used as a parameter can be seen in the URL when accessing the board through the web. The value appears after board/ in the following URL: https://game.naver.com/lounge/naver_game_developer/board/1?order=rank

The ID value that can be confirmed in pre-existing SDK management page has not been in use since version 1.2.0. Changes to the board ID values explained above are needed.

7. presentFeedViewControllerWith:scheduled: method

presentFeedViewControllerWith:scheduled: method used to show the details regarding the post. Takes the post’s ID as the parameter. The following is the code that uses the presentFeedViewControllerWith:scheduled: method to open the details page of the post with an ID of 12345.

[NNGSDKManager.shared presentFeedViewControllerWith:@12345 scheduled:NO];

The scheduled parameter shows whether the post had been scheduled or not. When a scheduled post is uploaded, an ID for the scheduled post, different from that of a regular post, is issued. The following is the code that opens the details page of a scheduled post with an ID of 123.

[NNGSDKManager.shared presentFeedViewControllerWith:@123 scheduled:YES];

Codes that use the ID of a scheduled page to open the details of a post functions normally even after the post is uploaded and the post ID is issued; therefore, the code does not need to be adjusted in the future.

If a banner connected to a post that had not yet been exposed, due to the scheduled time having not yet passed, is clicked, no action occurs.

8. presentFeedWritingWithBoardId:title:text:imageFilePath: Method

This method opens the details page of a given writing. All parameters such as boardId, title, text, imageFilePath values can all be omitted. If they are not omitted, the user will enter the writing page with those values already entered.

The following is an example of using presentFeedWritingWithBoardId:title:text:imageFilePath: Method to open a details page pertaining to the writing set to post an event registration post in Board No. 1.

[NNGSDKManager.shared presentFeedWritingWithBoardId:@1 title:@"[이벤트 참여] 스크린샷 이벤트" text:nil imageFilePath:nil];

9. dismiss method

The dismiss method is the method that closes the SDK screen. The following case is a demonstration of the implementation of the dismiss method.

[NNGSDKManager.shared dismiss];

Callback Delegate

By setting the callback delegate, the event that occurs from the plug can be processed.

Callback Delegate Registration

Register the target to process the callback delegate in the NNGSDKManager.

@interface ViewController () <NNGSDKManagerDelegate>
...
NNGSDKManager.shared.delegate = self;
...

Callback Delegate Implementation

1. nngSDKDidLoad method

This delegate is called whenever the SDK is running. The following case is a demonstration of the implementation of the nngSDKDidLoad method.

- (void)nngSDKDidLoad {
    NSLog(@"SDK is loaded.");
}

2. nngSDKDidUnload method

This delegate is called whenever the SDK is terminated. The following case is a demonstration of the implementation of the nngSDKDidUnload method.

- (void)nngSDKDidUnload {
    NSLog(@"SDK is unloaded.");
}

3. nngSDKDidReceiveInGameMenuCode: method

This delegate is called whenever an event that has been selected to receive an in-game menu code from the SDK occurs. It can be selected to receive an in-game menu code when the banner is clicked on in the management page, and from the same page, the string for the menu code can be inputted.

Because the string that had been inputted by the management page is delivered in its exact form, this can be checked to process the wanted action when an event occurs. The following case is a demonstration of the implementation of the nngSDKDidReceiveInGameMenuCode: method.

- (void)nngSDKDidReceiveInGameMenuCode:(NSString *)inGameMenuCode{
    [NNGSDKManager.shared dismiss];

    if ([inGameMenuCode isEqualToString:@"myMenuCode1"]) {
        // Do somthing for the in-game menu code "myMenuCode1"
    } else if ([inGameMenuCode isEqualToString:@"myMenuCode2"]) {
        // Do somthing for the in-game menu code "myMenuCode2"    
    }
}

nngSDKReceiveInGameMenuCode: This method does not close the SDK screen. If needed, add the code that closes the SDK screen as stated in line 2 of the example code above.

Last updated