# 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:

```sh
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`:

```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:

```java
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`):

```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:

```objective-c
#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;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.eternals.game/gdk-documentation/cocos-creator/installation-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
