Crates.io | play-games-services |
lib.rs | play-games-services |
version | 0.2.3 |
source | src |
created_at | 2022-08-10 16:52:15.361684 |
updated_at | 2022-09-12 13:56:55.688121 |
description | Google Play Games Services Plugin for Crossbow |
homepage | |
repository | https://github.com/dodorare/crossbow |
max_upload_size | |
id | 642731 |
size | 15,415 |
This project is a Crossbow Plugin for Google Play Games Services written in Rust and Kotlin.
Feature | Available |
---|---|
Sign-in/Sign out | ✅ |
Achievements | 🆗 |
Leaderboards | 🆗 |
Events | 🆗 |
Player Stats | 🆗 |
Player Info | 🆗 |
Saved Games | 🆗 |
✅ = Works and tested — 🆗 = Works but may contain bugs — 🛠 = Under development — 📝 = Planned - ❌ = Not working - ❗ = Not planned to be implemented
Just add Rust dependencies like this:
[dependencies]
crossbow = "0.2.3"
[target.'cfg(target_os = "android")'.dependencies]
play-games-services = "0.2.3"
And finally, add this to your Crossbow Android configuration:
[package.metadata.android]
plugins_remote = ["com.crossbow.play_games_services:play_games_services:0.2.3"]
Important: Before using this plugin please follow instructions on Setting Up Google Play Games Services official guide.
AndroidManifest
resourcesCreate you resources directory and import it by adding the following in your Cargo.toml
:
[package.metadata.android]
resources = ["./res/android"]
Then create file ./res/android/values/games-ids.xml
in your resources directory with the following content:
<?xml version="1.0" encoding="utf-8"?>
<!--Google Play game services IDs. Save this file as res/values/games-ids.xml in your project.-->
<resources>
<!--app_id-->
<string name="app_id" translatable="false">ADD_YOUR_APP_ID</string>
</resources>
Important: You need to replace
ADD_YOUR_APP_ID
with your app ID. Read official instructions to learn more.
Next, specify the package and meta_data for the Application's AndroidManifest.xml in your Cargo.toml
:
[package.metadata.android.manifest]
package = "com.crossbow.play_games"
[[package.metadata.android.manifest.application.meta_data]]
name = "com.google.android.gms.games.APP_ID"
value = "@string/app_id"
[[package.metadata.android.manifest.application.meta_data]]
name = "com.google.android.gms.version"
value = "@integer/google_play_services_version"
That's it, now you can start using Play Games Services!
First step is plugin initialization. In your rust project, you will need to initialize Crossbow
instance and then get Android plugin:
#![cfg(target_os = "android")]
use crossbow::android::*;
let crossbow = CrossbowInstance::new();
let play_games: play_games_services::PlayGamesServicesPlugin = crossbow.get_plugin()?;
// Initialize Google Play Games Services
play_games.init(true)?;
After plugin initialization you can use supported features. For example to SignIn user you can use:
play_games.sign_in()?;
To read signals:
if let Ok(signal) = play_games.get_receiver().recv().await {
println!("Signal: {:?}", signal);
}
Complete documentation you can find here.
Error 12501
- make sure that fingerprint, package, and resources are configured correctly. See similar StackOverflow question.Error 4
- make sure that you sign your Application with correct Play Store key.This Plugin was initially adapted and inspired by godot-pgsgp.