Installation Guide

Cocos Creator GDK Installation

Requirements

  • Node.js

  • Cocos Creator 3.8+

  • Minimum Android SDK version: 24

  • Minimum iOS version: 12.0

Before You Start

Before importing GDK into your project, please follow these instructions:

Android

  • Generate an Android build to create native/engine/android (skip if it already exists in your project).

  • Update minSdkVersion in native/engine/android/app/build.gradle to 24 (required by WalletCore).

iOS

  • Generate an iOS build to create native/engine/ios.

  • In the Build Panel, set OS Target to iPhoneOS and Target iOS Version to 12.0.

Import GDK to your project

Download the latest version here

Ensure that native/engine/android and native/engine/ios exist in your project.

You can import NEGdk using a script (requires Node.js) or manually.

Using Script

To import NEGdk into your project, run:

cd negdk
node ./scripts/import.js

You will be prompted to enter your project directory path.

Manual

If you want to import NEGdk manually into your project, follow these steps:

  • Copy negdk/assets/negdk into your project's <your_project>/assets folder.

  • Copy negdk/native into your project root folder.

  • Add dependencies from negdk/template/android/dependency.gradle to <your_project>/native/engine/android/app/build.gradle.

  • Append the contents of negdk/template/ios/CMakeLists.txt to <your_project>/native/engine/ios/CMakeLists.txt.

Platform Setup

Web Setup

  1. In Cocos Creator, select assets/negdk/plugins/web/negdk.js.

  2. In the Inspector, check Import As Plugin.

  3. Enable Load In Web, and disable Load In Native and Load In MiniGame.

  4. Click Save.

Android Setup

NEGDK uses Ramper to support social login on Android and iOS. Your app's scheme must be configured for this feature to work.

Configure Your App Scheme

Update your app's scheme in AndroidManifest.xml at <your_project>/native/engine/android/app/AndroidManifest.xml:

<activity android:name="com.cocos.game.AppActivity">
    <!-- Other configurations -->

    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="your_app_scheme"/>
    </intent-filter>
</activity>

Forwarding Activity Intent Callback to NEGDK

Modify your main activity file (<your_project>/native/engine/android/app/src/com/cocos/game/AppActivity.java) to forward intents to GDK:

import com.ne.gdk.NEGdk;

public class AppActivity extends CocosActivity {
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        SDKWrapper.shared().onNewIntent(intent);
        
        // Forward intent to GDK
        NEGdk.getInstance().onNewIntent(intent);
    }
}

iOS Setup

NEGDK uses Ramper for social login on iOS. Your app's scheme must be configured accordingly.

Configure Your App Scheme

Add the following CFBundleURLTypes block to Info.plist (<your_project>/native/engine/ios/Info.plist):

<dict>
    <!-- Other configurations -->
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>your_app_scheme</string>
            </array>
        </dict>
    </array>
</dict>

Forwarding Application openURL Callback to NEGDK

Modify AppDelegate.mm (native/engine/ios/AppDelegate.mm) to forward URL-based app openings to GDK:

#import <NEGdk/NEGdk.h>

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *)options {
    [[NEGdk sharedInstance] application:app openURL:url options:options];
    return YES;
}

Last updated