Interacting with Particle Auth within applications made using Cocos.
Particle Auth supports Cocos through the Particle Auth Cocos SDK, enabling full integration of Particle’s Wallet-as-a-Service within Cocos-based game applications.
The usage of Particle Auth with Cocos is nearly identical to React Native (JavaScript), with the main differences being in prerequisites and initial setup.
This document will guide you through the setup process. For usage examples, refer to the React Native (JavaScript) documentation.
To start the setup process for the Particle Auth Cocos SDK, make sure your project meets the following prerequisites to ensure compatibility:
Next, you’ll need to retrieve three essential values from the Particle dashboard, which are required across all of Particle’s SDKs: projectId
, clientKey
, and appId
.
Follow the quickstart tutorial to set up a project and find the required keys: Create a new project.
To install and start using the Particle Auth Cocos SDK in your project, follow these steps:
Locate the Core Assets directory:
particle-cocos
repository.Copy the Core Assets directory:
Core
folder to your project’s assets
directory.Locate the Native Engine directory:
particle-cocos
repository.Copy the Native Engine directory:
engine
directory to your project’s native
directory.If you’re using Cocos on Android, the configuration is quite simple and purely requires the placement of the previously retrieved values (projectId
, clientKey
, and appId
) within $exportDir/proj/gradle.properties,
such as within the example below.
If you use iOS, the initial configuration will be more complicated. To begin, ensure you have a Podfile.
If you don’t have one already, head over to the root of your Xcode project directory and run:
Head into this newly generated (or existing) Podfile and remove all existing contents, then paste the configuration included below.
Alternatively, if you’re already using other SDKs through CocoaPods, you can include the Particle Auth SDK declaration:
Additionally, you can run pod install --repo-update
, then open {your project}.xcworkspace
to update and see your project within Xcode.
Now that you’ve configured your Particle dashboard, installed the SDK, and configured a Podfile, it’s time to initialize the SDK with the aforementioned projectId
, clientKey
, and appId
retrieved from the Particle dashboard.
Create a ParticleNetwork-Info.plist
file from the root of your corresponding Xcode project.
Paste the following text into this file:
Replace the placeholders with the values retrieved from your project and application within the Particle dashboard.
Drop the following files into your project and set the target at the main app. Make sure Base58.swift
, Model.swift
, and ParticleAuthPlugin.swift
are marked within TargetMembership
.
AppDelegate
file and include a custom return within the (BOOL)application:openURL:options:
method, as shown in the example below:AppDelegate
, ensure a project-specific import is included at the top of the file. This should be #import "{project name}-Swift.h"
.JsbBridgeTest.m
and JsbBridgeTest.h
are crucial components, serving as the core bridge between JS and native code.
To prevent any issues arising from improper setup, ensure that the code within these files matches the code from the demo or includes the exact code from it.
Defining a scheme URL
Your scheme URL should be “pn” concatenated with your projectId
.
For example, if your project app id is
63bfa427-cf5f-4742-9ff1-e8f5a1b9828f
, your scheme URL is
pn63bfa427-cf5f-4742-9ff1-e8f5a1b9828f
.
Using the Particle Auth Cocos SDK is identical to the examples provided in the React Native (JavaScript) documentation.
The only difference is the import statement, which should include the internal path ../../Core/particleAuth
, as shown below:
Interacting with Particle Auth within applications made using Cocos.
Particle Auth supports Cocos through the Particle Auth Cocos SDK, enabling full integration of Particle’s Wallet-as-a-Service within Cocos-based game applications.
The usage of Particle Auth with Cocos is nearly identical to React Native (JavaScript), with the main differences being in prerequisites and initial setup.
This document will guide you through the setup process. For usage examples, refer to the React Native (JavaScript) documentation.
To start the setup process for the Particle Auth Cocos SDK, make sure your project meets the following prerequisites to ensure compatibility:
Next, you’ll need to retrieve three essential values from the Particle dashboard, which are required across all of Particle’s SDKs: projectId
, clientKey
, and appId
.
Follow the quickstart tutorial to set up a project and find the required keys: Create a new project.
To install and start using the Particle Auth Cocos SDK in your project, follow these steps:
Locate the Core Assets directory:
particle-cocos
repository.Copy the Core Assets directory:
Core
folder to your project’s assets
directory.Locate the Native Engine directory:
particle-cocos
repository.Copy the Native Engine directory:
engine
directory to your project’s native
directory.If you’re using Cocos on Android, the configuration is quite simple and purely requires the placement of the previously retrieved values (projectId
, clientKey
, and appId
) within $exportDir/proj/gradle.properties,
such as within the example below.
If you use iOS, the initial configuration will be more complicated. To begin, ensure you have a Podfile.
If you don’t have one already, head over to the root of your Xcode project directory and run:
Head into this newly generated (or existing) Podfile and remove all existing contents, then paste the configuration included below.
Alternatively, if you’re already using other SDKs through CocoaPods, you can include the Particle Auth SDK declaration:
Additionally, you can run pod install --repo-update
, then open {your project}.xcworkspace
to update and see your project within Xcode.
Now that you’ve configured your Particle dashboard, installed the SDK, and configured a Podfile, it’s time to initialize the SDK with the aforementioned projectId
, clientKey
, and appId
retrieved from the Particle dashboard.
Create a ParticleNetwork-Info.plist
file from the root of your corresponding Xcode project.
Paste the following text into this file:
Replace the placeholders with the values retrieved from your project and application within the Particle dashboard.
Drop the following files into your project and set the target at the main app. Make sure Base58.swift
, Model.swift
, and ParticleAuthPlugin.swift
are marked within TargetMembership
.
AppDelegate
file and include a custom return within the (BOOL)application:openURL:options:
method, as shown in the example below:AppDelegate
, ensure a project-specific import is included at the top of the file. This should be #import "{project name}-Swift.h"
.JsbBridgeTest.m
and JsbBridgeTest.h
are crucial components, serving as the core bridge between JS and native code.
To prevent any issues arising from improper setup, ensure that the code within these files matches the code from the demo or includes the exact code from it.
Defining a scheme URL
Your scheme URL should be “pn” concatenated with your projectId
.
For example, if your project app id is
63bfa427-cf5f-4742-9ff1-e8f5a1b9828f
, your scheme URL is
pn63bfa427-cf5f-4742-9ff1-e8f5a1b9828f
.
Using the Particle Auth Cocos SDK is identical to the examples provided in the React Native (JavaScript) documentation.
The only difference is the import statement, which should include the internal path ../../Core/particleAuth
, as shown below: