Chuyển tới nội dung chính

Unity Installation

com.alogame.sdk is a UPM package that wraps the same native SDKs described on the Android and iOS pages. Version 1.0.2 ships Android 1.5.5 and iOS 1.5.7 inside the package, so there is no .aar to copy, no .xcframework to drag into Xcode, no Podfile, and no External Dependency Manager.

Requirements: Unity 2022.3+, Android minSdkVersion 24+, iOS 15.0+. Install Android and/or iOS Build Support through Unity Hub: without the platform module the native code paths are compiled out, and a clean console proves nothing.

1. Add the package​

Window → Package Manager → + → Add package from git URL:

https://github.com/alo-game/alogame-sdk-unity.git#1.0.2

Pin the tag. Newer versions are listed under tags.

This is a release repo

It holds the compiled native SDKs for each tag plus the package's own C#, Java and Swift glue as readable source.

2. Add your Firebase files​

Put google-services.json (Android) and GoogleService-Info.plist (iOS) anywhere under Assets. The build hooks pick them up:

  • Android gets the Firebase resources the google-services Gradle plugin would generate (FCM push, Firebase Analytics). No Gradle template edits. If the Firebase Unity SDK is in the project, this step stands aside for it.
  • iOS gets the plist in the app bundle plus its REVERSED_CLIENT_ID URL scheme, which Google login on iOS needs.

There is no other config file. oeg_config.json is not read.

3. Initialize​

Call Initialize once at boot, with the game id from your Alogame operator, before any other Alogame.SDK call:

C#
using Alogame.SDK;
using UnityEngine;

public class Bootstrap : MonoBehaviour
{
private void Awake()
{
AlogameSDK.Initialize(53); // your game id
// AlogameSDK.Initialize(53, debugEnv: true); // dev backend + verbose logs, never in release
}
}

The game id, the bundle ID / package name and the platform must match what the backend has registered for the game. Otherwise remote config is rejected and every later call fails. Everything else (social login credentials, feature flags, tracking) is configured by Alogame on the server and loaded at runtime.

Every SDK call returns a Task. A call the SDK rejects throws AlogameSdkException (e.Error.Code, e.Message). A call that succeeds returns its result.

The Editor does not call the native SDK

AndroidJavaClass and DllImport("__Internal") are no-ops in the Editor, so Play mode resolves calls through a mock. Test on a device.

Next: Authentication.

What the build hooks do​

This is automatic. It is listed because when a build breaks, these are the things to suspect.

Android

  • fails the build early if the minimum API level is below 24;
  • adds the native SDK's Maven dependencies to the generated build.gradle. A vendored .aar carries no POM, so without this the APK installs and then crashes on the first SDK call with NoClassDefFoundError.

iOS

  • adds GoogleSignIn, FirebaseAnalytics and AppsFlyerLib-Static as Swift packages. The first iOS build therefore needs network access so Xcode can resolve them;
  • embeds OegSdkV2.framework (a dynamic framework) with the slice that matches the build target, device or simulator;
  • copies GoogleService-Info.plist and registers its URL scheme;
  • writes NSUserTrackingUsageDescription into Info.plist. Set your own wording on the AlogameSDKSettings asset (see Authentication).

Known behaviour​

Duplicate Objective-C classes on iOS. At launch the console prints many Class … is implemented in both warnings for Firebase, GoogleSignIn and GTM. They are expected and have not been seen to break anything. Do not add the Firebase or Google Sign-In Unity plugins on top.

Firebase is a no-op without GoogleService-Info.plist. The SDK logs that Firebase Analytics is disabled and continues.