capacitor-game-connect
capacitor-game-connect 사용하기
install
npm install @openforge/capacitor-game-connect
npx cap sync
android
AndroidManifest.xml
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/game_services_project_id"/>
app/src/main/res/values/strings.xml
Play Games Console의 Play Games Services setup 에서 관련 YOU_APP_ID를 획득할 수 있습니다.
<string translatable="false" name="game_services_project_id">YOU_APP_ID</string>
MainActivity.class
import com.openforge.capacitorgameconnect.CapacitorGameConnectPlugin;
..........
@Override
public void onCreate(Bundle savedInstanceState) {
registerPlugin(CapacitorGameConnectPlugin.class);
super.onCreate(savedInstanceState);
}
angular
import {CapacitorGameConnect} from '@openforge/capacitor-game-connect';
public async login() {
CapacitorGameConnect.signIn().then((response) => {
console.log('login >> response >>', response);
});
}
/**
* 업적 창을 띄움
*/
public async achievement() {
if (Capacitor.isNativePlatform()) {
CapacitorGameConnect.showAchievements();
}
}
/**
* 업적달성
* @param Object obj: {type, count}
*/
public async unLockAchievement(obj: any) {
if (Capacitor.isNativePlatform()) {
CapacitorGameConnect.unlockAchievement({
achievementID: achievementID // id of your achievement
});
}
}