@cond/simasdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CondSimasdk.podspec +1 -1
- package/Package.swift +3 -1
- package/android/build.gradle +4 -2
- package/android/src/main/java/com/simasdk/SimaGamesPlugin.java +235 -0
- package/dist/att.cjs +37 -0
- package/dist/att.cjs.map +1 -0
- package/dist/att.d.cts +31 -0
- package/dist/att.d.ts +31 -0
- package/dist/att.js +33 -0
- package/dist/att.js.map +1 -0
- package/dist/cli.js +64 -3
- package/dist/games.cjs +98 -0
- package/dist/games.cjs.map +1 -0
- package/dist/games.d.cts +73 -0
- package/dist/games.d.ts +73 -0
- package/dist/games.js +95 -0
- package/dist/games.js.map +1 -0
- package/ios/Sources/SimasdkPlugin/SimaAttPlugin.swift +41 -0
- package/ios/Sources/SimasdkPlugin/SimaGamesPlugin.swift +145 -0
- package/package.json +11 -1
package/CondSimasdk.podspec
CHANGED
|
@@ -13,6 +13,6 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.source_files = 'ios/Sources/SimasdkPlugin/**/*.{swift,h,m}'
|
|
14
14
|
s.ios.deployment_target = '14.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
|
-
s.frameworks = 'StoreKit'
|
|
16
|
+
s.frameworks = 'StoreKit', 'GameKit', 'AppTrackingTransparency'
|
|
17
17
|
s.swift_version = '5.9'
|
|
18
18
|
end
|
package/Package.swift
CHANGED
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
ext {
|
|
2
2
|
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
3
3
|
playReviewVersion = project.hasProperty('simaPlayReviewVersion') ? rootProject.ext.simaPlayReviewVersion : '2.0.2'
|
|
4
|
+
playGamesVersion = project.hasProperty('simaPlayGamesVersion') ? rootProject.ext.simaPlayGamesVersion : '20.1.2'
|
|
4
5
|
firebaseBomVersion = project.hasProperty('simaFirebaseBomVersion') ? rootProject.ext.simaFirebaseBomVersion : '35.2.0'
|
|
5
6
|
}
|
|
6
7
|
|
|
@@ -54,8 +55,9 @@ dependencies {
|
|
|
54
55
|
// Included for simasdk/review (Google Play In-App Review).
|
|
55
56
|
implementation "com.google.android.play:review:$playReviewVersion"
|
|
56
57
|
|
|
57
|
-
// compileOnly ensures Firebase Analytics
|
|
58
|
-
// the host app explicitly declares
|
|
58
|
+
// compileOnly ensures Firebase Analytics and Play Games Services are NEVER pulled into APKs/AABs
|
|
59
|
+
// unless the host app explicitly declares them in android/app/build.gradle.
|
|
59
60
|
compileOnly platform("com.google.firebase:firebase-bom:$firebaseBomVersion")
|
|
60
61
|
compileOnly "com.google.firebase:firebase-analytics"
|
|
62
|
+
compileOnly "com.google.android.gms:play-services-games-v2:$playGamesVersion"
|
|
61
63
|
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
package com.simasdk;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.Intent;
|
|
5
|
+
import androidx.activity.result.ActivityResult;
|
|
6
|
+
import com.getcapacitor.JSObject;
|
|
7
|
+
import com.getcapacitor.Plugin;
|
|
8
|
+
import com.getcapacitor.PluginCall;
|
|
9
|
+
import com.getcapacitor.PluginMethod;
|
|
10
|
+
import com.getcapacitor.annotation.ActivityCallback;
|
|
11
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
12
|
+
import com.google.android.gms.games.GamesSignInClient;
|
|
13
|
+
import com.google.android.gms.games.LeaderboardsClient;
|
|
14
|
+
import com.google.android.gms.games.PlayGames;
|
|
15
|
+
import com.google.android.gms.games.leaderboard.LeaderboardVariant;
|
|
16
|
+
|
|
17
|
+
@CapacitorPlugin(name = "SimaGames")
|
|
18
|
+
public class SimaGamesPlugin extends Plugin {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Separate helper class so Play Games SDK classes are resolved lazily
|
|
22
|
+
* only after confirming the host app linked play-services-games-v2.
|
|
23
|
+
*/
|
|
24
|
+
private static final class PlayGamesBridge {
|
|
25
|
+
static void isAuthenticated(Activity activity, PluginCall call) {
|
|
26
|
+
PlayGames.getGamesSignInClient(activity)
|
|
27
|
+
.isAuthenticated()
|
|
28
|
+
.addOnCompleteListener(task -> {
|
|
29
|
+
boolean ok = task.isSuccessful() && task.getResult().isAuthenticated();
|
|
30
|
+
JSObject ret = new JSObject();
|
|
31
|
+
ret.put("authenticated", ok);
|
|
32
|
+
call.resolve(ret);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static void signIn(Activity activity, PluginCall call) {
|
|
37
|
+
GamesSignInClient client = PlayGames.getGamesSignInClient(activity);
|
|
38
|
+
client.isAuthenticated().addOnCompleteListener(authTask -> {
|
|
39
|
+
boolean already = authTask.isSuccessful() && authTask.getResult().isAuthenticated();
|
|
40
|
+
if (already) {
|
|
41
|
+
JSObject ret = new JSObject();
|
|
42
|
+
ret.put("authenticated", true);
|
|
43
|
+
call.resolve(ret);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
client.signIn().addOnCompleteListener(signInTask -> {
|
|
47
|
+
boolean ok = signInTask.isSuccessful() && signInTask.getResult().isAuthenticated();
|
|
48
|
+
JSObject ret = new JSObject();
|
|
49
|
+
ret.put("authenticated", ok);
|
|
50
|
+
call.resolve(ret);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static void submitScore(Activity activity, String leaderboardId, long score, PluginCall call) {
|
|
56
|
+
PlayGames.getGamesSignInClient(activity)
|
|
57
|
+
.isAuthenticated()
|
|
58
|
+
.addOnCompleteListener(authTask -> {
|
|
59
|
+
boolean ok = authTask.isSuccessful() && authTask.getResult().isAuthenticated();
|
|
60
|
+
if (!ok) {
|
|
61
|
+
JSObject ret = new JSObject();
|
|
62
|
+
ret.put("submitted", false);
|
|
63
|
+
call.resolve(ret);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
LeaderboardsClient client = PlayGames.getLeaderboardsClient(activity);
|
|
67
|
+
client.submitScoreImmediate(leaderboardId, score)
|
|
68
|
+
.addOnSuccessListener(data -> {
|
|
69
|
+
JSObject ret = new JSObject();
|
|
70
|
+
ret.put("submitted", true);
|
|
71
|
+
call.resolve(ret);
|
|
72
|
+
})
|
|
73
|
+
.addOnFailureListener(err -> {
|
|
74
|
+
// Fire-and-forget fallback supports offline queuing
|
|
75
|
+
client.submitScore(leaderboardId, score);
|
|
76
|
+
JSObject ret = new JSObject();
|
|
77
|
+
ret.put("submitted", true);
|
|
78
|
+
call.resolve(ret);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static void getLeaderboardIntent(
|
|
84
|
+
Activity activity,
|
|
85
|
+
String leaderboardId,
|
|
86
|
+
String timeSpan,
|
|
87
|
+
SimaGamesPlugin plugin,
|
|
88
|
+
PluginCall call
|
|
89
|
+
) {
|
|
90
|
+
int span = LeaderboardVariant.TIME_SPAN_ALL_TIME;
|
|
91
|
+
if ("daily".equalsIgnoreCase(timeSpan)) {
|
|
92
|
+
span = LeaderboardVariant.TIME_SPAN_DAILY;
|
|
93
|
+
} else if ("weekly".equalsIgnoreCase(timeSpan)) {
|
|
94
|
+
span = LeaderboardVariant.TIME_SPAN_WEEKLY;
|
|
95
|
+
}
|
|
96
|
+
PlayGames.getLeaderboardsClient(activity)
|
|
97
|
+
.getLeaderboardIntent(leaderboardId, span, LeaderboardVariant.COLLECTION_PUBLIC)
|
|
98
|
+
.addOnSuccessListener(intent -> plugin.launchLeaderboard(call, intent))
|
|
99
|
+
.addOnFailureListener(err -> call.reject("Failed to open leaderboard.", "LEADERBOARD_ERROR", err));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static void unlockAchievement(Activity activity, String achievementId, PluginCall call) {
|
|
103
|
+
PlayGames.getGamesSignInClient(activity)
|
|
104
|
+
.isAuthenticated()
|
|
105
|
+
.addOnCompleteListener(authTask -> {
|
|
106
|
+
boolean ok = authTask.isSuccessful() && authTask.getResult().isAuthenticated();
|
|
107
|
+
if (!ok) {
|
|
108
|
+
JSObject ret = new JSObject();
|
|
109
|
+
ret.put("unlocked", false);
|
|
110
|
+
call.resolve(ret);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
PlayGames.getAchievementsClient(activity).unlock(achievementId);
|
|
114
|
+
JSObject ret = new JSObject();
|
|
115
|
+
ret.put("unlocked", true);
|
|
116
|
+
call.resolve(ret);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private boolean isPlayGamesSdkOnClasspath() {
|
|
122
|
+
try {
|
|
123
|
+
Class.forName("com.google.android.gms.games.PlayGames");
|
|
124
|
+
return true;
|
|
125
|
+
} catch (ClassNotFoundException ignored) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private void launchLeaderboard(PluginCall call, Intent intent) {
|
|
131
|
+
startActivityForResult(call, intent, "handleLeaderboardResult");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@ActivityCallback
|
|
135
|
+
private void handleLeaderboardResult(PluginCall call, ActivityResult result) {
|
|
136
|
+
JSObject ret = new JSObject();
|
|
137
|
+
ret.put("shown", true);
|
|
138
|
+
call.resolve(ret);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
@PluginMethod
|
|
142
|
+
public void isAuthenticated(PluginCall call) {
|
|
143
|
+
if (!isPlayGamesSdkOnClasspath() || getActivity() == null) {
|
|
144
|
+
JSObject ret = new JSObject();
|
|
145
|
+
ret.put("authenticated", false);
|
|
146
|
+
call.resolve(ret);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
PlayGamesBridge.isAuthenticated(getActivity(), call);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@PluginMethod
|
|
153
|
+
public void signIn(PluginCall call) {
|
|
154
|
+
if (!isPlayGamesSdkOnClasspath()) {
|
|
155
|
+
call.reject(
|
|
156
|
+
"Google Play Games Services v2 SDK is not included. Add com.google.android.gms:play-services-games-v2 to android/app/build.gradle.",
|
|
157
|
+
"NOT_CONFIGURED"
|
|
158
|
+
);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
Activity activity = getActivity();
|
|
162
|
+
if (activity == null) {
|
|
163
|
+
call.reject("Activity not available.", "NO_ACTIVITY");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
PlayGamesBridge.signIn(activity, call);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@PluginMethod
|
|
170
|
+
public void submitScore(PluginCall call) {
|
|
171
|
+
if (!isPlayGamesSdkOnClasspath()) {
|
|
172
|
+
JSObject ret = new JSObject();
|
|
173
|
+
ret.put("submitted", false);
|
|
174
|
+
call.resolve(ret);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
String leaderboardId = call.getString("leaderboardId", "").trim();
|
|
178
|
+
// Use getDouble + Math.round so both Integer and Long JSON numbers are handled safely.
|
|
179
|
+
Double scoreDouble = call.getDouble("score");
|
|
180
|
+
if (leaderboardId.isEmpty() || scoreDouble == null || !Double.isFinite(scoreDouble)) {
|
|
181
|
+
call.reject("leaderboardId and finite numeric score are required.", "INVALID_ARGUMENT");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
Activity activity = getActivity();
|
|
185
|
+
if (activity == null) {
|
|
186
|
+
call.reject("Activity not available.", "NO_ACTIVITY");
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
PlayGamesBridge.submitScore(activity, leaderboardId, Math.round(scoreDouble), call);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@PluginMethod
|
|
193
|
+
public void showLeaderboard(PluginCall call) {
|
|
194
|
+
if (!isPlayGamesSdkOnClasspath()) {
|
|
195
|
+
call.reject(
|
|
196
|
+
"Google Play Games Services v2 SDK is not included. Add com.google.android.gms:play-services-games-v2 to android/app/build.gradle.",
|
|
197
|
+
"NOT_CONFIGURED"
|
|
198
|
+
);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
String leaderboardId = call.getString("leaderboardId", "").trim();
|
|
202
|
+
String timeSpan = call.getString("timeSpan", "allTime");
|
|
203
|
+
if (leaderboardId.isEmpty()) {
|
|
204
|
+
call.reject("leaderboardId is required.", "INVALID_ARGUMENT");
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
Activity activity = getActivity();
|
|
208
|
+
if (activity == null) {
|
|
209
|
+
call.reject("Activity not available.", "NO_ACTIVITY");
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
PlayGamesBridge.getLeaderboardIntent(activity, leaderboardId, timeSpan, this, call);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
@PluginMethod
|
|
216
|
+
public void unlockAchievement(PluginCall call) {
|
|
217
|
+
if (!isPlayGamesSdkOnClasspath()) {
|
|
218
|
+
JSObject ret = new JSObject();
|
|
219
|
+
ret.put("unlocked", false);
|
|
220
|
+
call.resolve(ret);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
String achievementId = call.getString("achievementId", "").trim();
|
|
224
|
+
if (achievementId.isEmpty()) {
|
|
225
|
+
call.reject("achievementId is required.", "INVALID_ARGUMENT");
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
Activity activity = getActivity();
|
|
229
|
+
if (activity == null) {
|
|
230
|
+
call.reject("Activity not available.", "NO_ACTIVITY");
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
PlayGamesBridge.unlockAchievement(activity, achievementId, call);
|
|
234
|
+
}
|
|
235
|
+
}
|
package/dist/att.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
// src/att.ts
|
|
6
|
+
var SimaAtt = core.registerPlugin("SimaAtt");
|
|
7
|
+
var defaultDriver = {
|
|
8
|
+
isSupported() {
|
|
9
|
+
return typeof window !== "undefined" && core.Capacitor.isNativePlatform() && core.Capacitor.getPlatform() === "ios" && core.Capacitor.isPluginAvailable("SimaAtt");
|
|
10
|
+
},
|
|
11
|
+
getStatus: () => SimaAtt.getStatus(),
|
|
12
|
+
requestAuthorization: () => SimaAtt.requestAuthorization()
|
|
13
|
+
};
|
|
14
|
+
async function getTrackingStatus(driver = defaultDriver) {
|
|
15
|
+
if (!driver.isSupported()) return "unsupported";
|
|
16
|
+
try {
|
|
17
|
+
const res = await driver.getStatus();
|
|
18
|
+
return res?.status ?? "not_determined";
|
|
19
|
+
} catch {
|
|
20
|
+
return "unsupported";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function requestTrackingAuthorization(driver = defaultDriver) {
|
|
24
|
+
if (!driver.isSupported()) return "unsupported";
|
|
25
|
+
try {
|
|
26
|
+
const res = await driver.requestAuthorization();
|
|
27
|
+
return res?.status ?? "denied";
|
|
28
|
+
} catch {
|
|
29
|
+
return "denied";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.SimaAtt = SimaAtt;
|
|
34
|
+
exports.getTrackingStatus = getTrackingStatus;
|
|
35
|
+
exports.requestTrackingAuthorization = requestTrackingAuthorization;
|
|
36
|
+
//# sourceMappingURL=att.cjs.map
|
|
37
|
+
//# sourceMappingURL=att.cjs.map
|
package/dist/att.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/att.ts"],"names":["registerPlugin","Capacitor"],"mappings":";;;;;AAcO,IAAM,OAAA,GAAUA,oBAAoC,SAAS;AAQpE,IAAM,aAAA,GAA2B;AAAA,EAC/B,WAAA,GAAuB;AACrB,IAAA,OACE,OAAO,MAAA,KAAW,WAAA,IAClBC,cAAA,CAAU,gBAAA,EAAiB,IAC3BA,cAAA,CAAU,WAAA,EAAY,KAAM,KAAA,IAC5BA,cAAA,CAAU,iBAAA,CAAkB,SAAS,CAAA;AAAA,EAEzC,CAAA;AAAA,EACA,SAAA,EAAW,MAAM,OAAA,CAAQ,SAAA,EAAU;AAAA,EACnC,oBAAA,EAAsB,MAAM,OAAA,CAAQ,oBAAA;AACtC,CAAA;AAMA,eAAsB,iBAAA,CACpB,SAAoB,aAAA,EACkB;AACtC,EAAA,IAAI,CAAC,MAAA,CAAO,WAAA,EAAY,EAAG,OAAO,aAAA;AAClC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAM,MAAA,CAAO,SAAA,EAAU;AACnC,IAAA,OAAO,KAAK,MAAA,IAAU,gBAAA;AAAA,EACxB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,aAAA;AAAA,EACT;AACF;AAMA,eAAsB,4BAAA,CACpB,SAAoB,aAAA,EACkB;AACtC,EAAA,IAAI,CAAC,MAAA,CAAO,WAAA,EAAY,EAAG,OAAO,aAAA;AAClC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAM,MAAA,CAAO,oBAAA,EAAqB;AAC9C,IAAA,OAAO,KAAK,MAAA,IAAU,QAAA;AAAA,EACxB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,QAAA;AAAA,EACT;AACF","file":"att.cjs","sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\n\nexport type TrackingAuthorizationStatus =\n | 'authorized'\n | 'denied'\n | 'restricted'\n | 'not_determined'\n | 'unsupported';\n\nexport interface SimaAttNativePlugin {\n getStatus(): Promise<{ status: Exclude<TrackingAuthorizationStatus, 'unsupported'> }>;\n requestAuthorization(): Promise<{ status: Exclude<TrackingAuthorizationStatus, 'unsupported'> }>;\n}\n\nexport const SimaAtt = registerPlugin<SimaAttNativePlugin>('SimaAtt');\n\nexport interface AttDriver {\n isSupported(): boolean;\n getStatus(): Promise<{ status: Exclude<TrackingAuthorizationStatus, 'unsupported'> }>;\n requestAuthorization(): Promise<{ status: Exclude<TrackingAuthorizationStatus, 'unsupported'> }>;\n}\n\nconst defaultDriver: AttDriver = {\n isSupported(): boolean {\n return (\n typeof window !== 'undefined' &&\n Capacitor.isNativePlatform() &&\n Capacitor.getPlatform() === 'ios' &&\n Capacitor.isPluginAvailable('SimaAtt')\n );\n },\n getStatus: () => SimaAtt.getStatus(),\n requestAuthorization: () => SimaAtt.requestAuthorization(),\n};\n\n/**\n * Reads current iOS App Tracking Transparency (ATT) status without showing a prompt.\n * Returns `'unsupported'` on Android, web, and SSR.\n */\nexport async function getTrackingStatus(\n driver: AttDriver = defaultDriver,\n): Promise<TrackingAuthorizationStatus> {\n if (!driver.isSupported()) return 'unsupported';\n try {\n const res = await driver.getStatus();\n return res?.status ?? 'not_determined';\n } catch {\n return 'unsupported';\n }\n}\n\n/**\n * Requests iOS App Tracking Transparency (ATT) permission (IDFA for Google Ads attribution).\n * Safe no-op returning `'unsupported'` on Android, web, and SSR. Never throws.\n */\nexport async function requestTrackingAuthorization(\n driver: AttDriver = defaultDriver,\n): Promise<TrackingAuthorizationStatus> {\n if (!driver.isSupported()) return 'unsupported';\n try {\n const res = await driver.requestAuthorization();\n return res?.status ?? 'denied';\n } catch {\n return 'denied';\n }\n}\n"]}
|
package/dist/att.d.cts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type TrackingAuthorizationStatus = 'authorized' | 'denied' | 'restricted' | 'not_determined' | 'unsupported';
|
|
2
|
+
interface SimaAttNativePlugin {
|
|
3
|
+
getStatus(): Promise<{
|
|
4
|
+
status: Exclude<TrackingAuthorizationStatus, 'unsupported'>;
|
|
5
|
+
}>;
|
|
6
|
+
requestAuthorization(): Promise<{
|
|
7
|
+
status: Exclude<TrackingAuthorizationStatus, 'unsupported'>;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
declare const SimaAtt: SimaAttNativePlugin;
|
|
11
|
+
interface AttDriver {
|
|
12
|
+
isSupported(): boolean;
|
|
13
|
+
getStatus(): Promise<{
|
|
14
|
+
status: Exclude<TrackingAuthorizationStatus, 'unsupported'>;
|
|
15
|
+
}>;
|
|
16
|
+
requestAuthorization(): Promise<{
|
|
17
|
+
status: Exclude<TrackingAuthorizationStatus, 'unsupported'>;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reads current iOS App Tracking Transparency (ATT) status without showing a prompt.
|
|
22
|
+
* Returns `'unsupported'` on Android, web, and SSR.
|
|
23
|
+
*/
|
|
24
|
+
declare function getTrackingStatus(driver?: AttDriver): Promise<TrackingAuthorizationStatus>;
|
|
25
|
+
/**
|
|
26
|
+
* Requests iOS App Tracking Transparency (ATT) permission (IDFA for Google Ads attribution).
|
|
27
|
+
* Safe no-op returning `'unsupported'` on Android, web, and SSR. Never throws.
|
|
28
|
+
*/
|
|
29
|
+
declare function requestTrackingAuthorization(driver?: AttDriver): Promise<TrackingAuthorizationStatus>;
|
|
30
|
+
|
|
31
|
+
export { type AttDriver, SimaAtt, type SimaAttNativePlugin, type TrackingAuthorizationStatus, getTrackingStatus, requestTrackingAuthorization };
|
package/dist/att.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type TrackingAuthorizationStatus = 'authorized' | 'denied' | 'restricted' | 'not_determined' | 'unsupported';
|
|
2
|
+
interface SimaAttNativePlugin {
|
|
3
|
+
getStatus(): Promise<{
|
|
4
|
+
status: Exclude<TrackingAuthorizationStatus, 'unsupported'>;
|
|
5
|
+
}>;
|
|
6
|
+
requestAuthorization(): Promise<{
|
|
7
|
+
status: Exclude<TrackingAuthorizationStatus, 'unsupported'>;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
declare const SimaAtt: SimaAttNativePlugin;
|
|
11
|
+
interface AttDriver {
|
|
12
|
+
isSupported(): boolean;
|
|
13
|
+
getStatus(): Promise<{
|
|
14
|
+
status: Exclude<TrackingAuthorizationStatus, 'unsupported'>;
|
|
15
|
+
}>;
|
|
16
|
+
requestAuthorization(): Promise<{
|
|
17
|
+
status: Exclude<TrackingAuthorizationStatus, 'unsupported'>;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reads current iOS App Tracking Transparency (ATT) status without showing a prompt.
|
|
22
|
+
* Returns `'unsupported'` on Android, web, and SSR.
|
|
23
|
+
*/
|
|
24
|
+
declare function getTrackingStatus(driver?: AttDriver): Promise<TrackingAuthorizationStatus>;
|
|
25
|
+
/**
|
|
26
|
+
* Requests iOS App Tracking Transparency (ATT) permission (IDFA for Google Ads attribution).
|
|
27
|
+
* Safe no-op returning `'unsupported'` on Android, web, and SSR. Never throws.
|
|
28
|
+
*/
|
|
29
|
+
declare function requestTrackingAuthorization(driver?: AttDriver): Promise<TrackingAuthorizationStatus>;
|
|
30
|
+
|
|
31
|
+
export { type AttDriver, SimaAtt, type SimaAttNativePlugin, type TrackingAuthorizationStatus, getTrackingStatus, requestTrackingAuthorization };
|
package/dist/att.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { registerPlugin, Capacitor } from '@capacitor/core';
|
|
2
|
+
|
|
3
|
+
// src/att.ts
|
|
4
|
+
var SimaAtt = registerPlugin("SimaAtt");
|
|
5
|
+
var defaultDriver = {
|
|
6
|
+
isSupported() {
|
|
7
|
+
return typeof window !== "undefined" && Capacitor.isNativePlatform() && Capacitor.getPlatform() === "ios" && Capacitor.isPluginAvailable("SimaAtt");
|
|
8
|
+
},
|
|
9
|
+
getStatus: () => SimaAtt.getStatus(),
|
|
10
|
+
requestAuthorization: () => SimaAtt.requestAuthorization()
|
|
11
|
+
};
|
|
12
|
+
async function getTrackingStatus(driver = defaultDriver) {
|
|
13
|
+
if (!driver.isSupported()) return "unsupported";
|
|
14
|
+
try {
|
|
15
|
+
const res = await driver.getStatus();
|
|
16
|
+
return res?.status ?? "not_determined";
|
|
17
|
+
} catch {
|
|
18
|
+
return "unsupported";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async function requestTrackingAuthorization(driver = defaultDriver) {
|
|
22
|
+
if (!driver.isSupported()) return "unsupported";
|
|
23
|
+
try {
|
|
24
|
+
const res = await driver.requestAuthorization();
|
|
25
|
+
return res?.status ?? "denied";
|
|
26
|
+
} catch {
|
|
27
|
+
return "denied";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { SimaAtt, getTrackingStatus, requestTrackingAuthorization };
|
|
32
|
+
//# sourceMappingURL=att.js.map
|
|
33
|
+
//# sourceMappingURL=att.js.map
|
package/dist/att.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/att.ts"],"names":[],"mappings":";;;AAcO,IAAM,OAAA,GAAU,eAAoC,SAAS;AAQpE,IAAM,aAAA,GAA2B;AAAA,EAC/B,WAAA,GAAuB;AACrB,IAAA,OACE,OAAO,MAAA,KAAW,WAAA,IAClB,SAAA,CAAU,gBAAA,EAAiB,IAC3B,SAAA,CAAU,WAAA,EAAY,KAAM,KAAA,IAC5B,SAAA,CAAU,iBAAA,CAAkB,SAAS,CAAA;AAAA,EAEzC,CAAA;AAAA,EACA,SAAA,EAAW,MAAM,OAAA,CAAQ,SAAA,EAAU;AAAA,EACnC,oBAAA,EAAsB,MAAM,OAAA,CAAQ,oBAAA;AACtC,CAAA;AAMA,eAAsB,iBAAA,CACpB,SAAoB,aAAA,EACkB;AACtC,EAAA,IAAI,CAAC,MAAA,CAAO,WAAA,EAAY,EAAG,OAAO,aAAA;AAClC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAM,MAAA,CAAO,SAAA,EAAU;AACnC,IAAA,OAAO,KAAK,MAAA,IAAU,gBAAA;AAAA,EACxB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,aAAA;AAAA,EACT;AACF;AAMA,eAAsB,4BAAA,CACpB,SAAoB,aAAA,EACkB;AACtC,EAAA,IAAI,CAAC,MAAA,CAAO,WAAA,EAAY,EAAG,OAAO,aAAA;AAClC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAM,MAAA,CAAO,oBAAA,EAAqB;AAC9C,IAAA,OAAO,KAAK,MAAA,IAAU,QAAA;AAAA,EACxB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,QAAA;AAAA,EACT;AACF","file":"att.js","sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\n\nexport type TrackingAuthorizationStatus =\n | 'authorized'\n | 'denied'\n | 'restricted'\n | 'not_determined'\n | 'unsupported';\n\nexport interface SimaAttNativePlugin {\n getStatus(): Promise<{ status: Exclude<TrackingAuthorizationStatus, 'unsupported'> }>;\n requestAuthorization(): Promise<{ status: Exclude<TrackingAuthorizationStatus, 'unsupported'> }>;\n}\n\nexport const SimaAtt = registerPlugin<SimaAttNativePlugin>('SimaAtt');\n\nexport interface AttDriver {\n isSupported(): boolean;\n getStatus(): Promise<{ status: Exclude<TrackingAuthorizationStatus, 'unsupported'> }>;\n requestAuthorization(): Promise<{ status: Exclude<TrackingAuthorizationStatus, 'unsupported'> }>;\n}\n\nconst defaultDriver: AttDriver = {\n isSupported(): boolean {\n return (\n typeof window !== 'undefined' &&\n Capacitor.isNativePlatform() &&\n Capacitor.getPlatform() === 'ios' &&\n Capacitor.isPluginAvailable('SimaAtt')\n );\n },\n getStatus: () => SimaAtt.getStatus(),\n requestAuthorization: () => SimaAtt.requestAuthorization(),\n};\n\n/**\n * Reads current iOS App Tracking Transparency (ATT) status without showing a prompt.\n * Returns `'unsupported'` on Android, web, and SSR.\n */\nexport async function getTrackingStatus(\n driver: AttDriver = defaultDriver,\n): Promise<TrackingAuthorizationStatus> {\n if (!driver.isSupported()) return 'unsupported';\n try {\n const res = await driver.getStatus();\n return res?.status ?? 'not_determined';\n } catch {\n return 'unsupported';\n }\n}\n\n/**\n * Requests iOS App Tracking Transparency (ATT) permission (IDFA for Google Ads attribution).\n * Safe no-op returning `'unsupported'` on Android, web, and SSR. Never throws.\n */\nexport async function requestTrackingAuthorization(\n driver: AttDriver = defaultDriver,\n): Promise<TrackingAuthorizationStatus> {\n if (!driver.isSupported()) return 'unsupported';\n try {\n const res = await driver.requestAuthorization();\n return res?.status ?? 'denied';\n } catch {\n return 'denied';\n }\n}\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -125,7 +125,9 @@ function runDoctor(cwd) {
|
|
|
125
125
|
"SimaReviewPlugin",
|
|
126
126
|
"SimaFirebasePlugin",
|
|
127
127
|
"SimaHapticsPlugin",
|
|
128
|
-
"SimaStoragePlugin"
|
|
128
|
+
"SimaStoragePlugin",
|
|
129
|
+
"SimaGamesPlugin",
|
|
130
|
+
"SimaAttPlugin"
|
|
129
131
|
];
|
|
130
132
|
const missingIosPlugins = expectedIosPlugins.filter((p) => !classList.includes(p));
|
|
131
133
|
if (simasdkVersion) {
|
|
@@ -133,7 +135,7 @@ function runDoctor(cwd) {
|
|
|
133
135
|
checks.push({
|
|
134
136
|
id: "ios-plugin-sync",
|
|
135
137
|
status: "pass",
|
|
136
|
-
message:
|
|
138
|
+
message: `All ${expectedIosPlugins.length} simasdk iOS plugins are synced in ios/App/App/capacitor.config.json.`
|
|
137
139
|
});
|
|
138
140
|
} else {
|
|
139
141
|
checks.push({
|
|
@@ -231,6 +233,20 @@ function runDoctor(cwd) {
|
|
|
231
233
|
hint: "Remember to call sima.setAnalyticsCollectionEnabled(true) after user consent."
|
|
232
234
|
});
|
|
233
235
|
}
|
|
236
|
+
const attDesc = extractPlistString(infoPlist, "NSUserTrackingUsageDescription");
|
|
237
|
+
if (attDesc) {
|
|
238
|
+
checks.push({
|
|
239
|
+
id: "ios-att-description",
|
|
240
|
+
status: "pass",
|
|
241
|
+
message: "NSUserTrackingUsageDescription is configured in Info.plist for App Tracking Transparency."
|
|
242
|
+
});
|
|
243
|
+
} else {
|
|
244
|
+
checks.push({
|
|
245
|
+
id: "ios-att-description",
|
|
246
|
+
status: "info",
|
|
247
|
+
message: "No NSUserTrackingUsageDescription in Info.plist (required if using @cond/simasdk/att for IDFA)."
|
|
248
|
+
});
|
|
249
|
+
}
|
|
234
250
|
}
|
|
235
251
|
}
|
|
236
252
|
}
|
|
@@ -285,6 +301,51 @@ function runDoctor(cwd) {
|
|
|
285
301
|
});
|
|
286
302
|
}
|
|
287
303
|
}
|
|
304
|
+
const appGradleAny = readTextIfExists(path.join(cwd, "android/app/build.gradle")) ?? "";
|
|
305
|
+
const manifestAny = readTextIfExists(path.join(cwd, "android/app/src/main/AndroidManifest.xml")) ?? "";
|
|
306
|
+
if (appGradleAny.includes("play-services-games-v2")) {
|
|
307
|
+
if (manifestAny.includes("com.google.android.gms.games.APP_ID")) {
|
|
308
|
+
const stringsXml = readTextIfExists(path.join(cwd, "android/app/src/main/res/values/strings.xml")) ?? "";
|
|
309
|
+
if (stringsXml.includes(">000000000000<")) {
|
|
310
|
+
checks.push({
|
|
311
|
+
id: "android-play-games-id",
|
|
312
|
+
status: "warn",
|
|
313
|
+
message: "Play Games Services project ID is still a placeholder (000000000000) in strings.xml.",
|
|
314
|
+
hint: "Replace it with your numeric Project ID from Google Play Console -> Play Games Services."
|
|
315
|
+
});
|
|
316
|
+
} else {
|
|
317
|
+
checks.push({
|
|
318
|
+
id: "android-play-games-id",
|
|
319
|
+
status: "pass",
|
|
320
|
+
message: "Play Games Services v2 dependency and APP_ID meta-data are configured."
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
} else {
|
|
324
|
+
checks.push({
|
|
325
|
+
id: "android-play-games-id",
|
|
326
|
+
status: "fail",
|
|
327
|
+
message: "play-services-games-v2 is in build.gradle, but com.google.android.gms.games.APP_ID is missing in AndroidManifest.xml.",
|
|
328
|
+
hint: 'Add <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/game_services_project_id" /> inside <application>.'
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (allDeps["@capacitor-community/admob"]) {
|
|
333
|
+
const stylesXml = readTextIfExists(path.join(cwd, "android/app/src/main/res/values/styles.xml")) ?? "";
|
|
334
|
+
if (stylesXml.includes('android:background">@null<')) {
|
|
335
|
+
checks.push({
|
|
336
|
+
id: "android-admob-styles-bg",
|
|
337
|
+
status: "pass",
|
|
338
|
+
message: 'android/app/src/main/res/values/styles.xml sets android:background="@null" (prevents floating AdMob banner bug).'
|
|
339
|
+
});
|
|
340
|
+
} else if (stylesXml) {
|
|
341
|
+
checks.push({
|
|
342
|
+
id: "android-admob-styles-bg",
|
|
343
|
+
status: "warn",
|
|
344
|
+
message: '@capacitor-community/admob is installed, but styles.xml is missing <item name="android:background">@null</item>.',
|
|
345
|
+
hint: 'Add <item name="android:background">@null</item> to AppTheme.NoActionBar so AdView does not inherit splash background and float.'
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
288
349
|
}
|
|
289
350
|
const ok = !checks.some((c) => c.status === "fail");
|
|
290
351
|
return { cwd, ok, capacitorVersion: capVersion, hasIos, hasAndroid, checks };
|
|
@@ -544,7 +605,7 @@ function main(argv = process.argv.slice(2)) {
|
|
|
544
605
|
if (command === "--version" || command === "-v") {
|
|
545
606
|
const pkgPath = new URL("../package.json", import.meta.url);
|
|
546
607
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
547
|
-
console.log(pkg.version ?? "0.
|
|
608
|
+
console.log(pkg.version ?? "0.2.0");
|
|
548
609
|
return 0;
|
|
549
610
|
}
|
|
550
611
|
if (command === "doctor") {
|
package/dist/games.cjs
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
// src/games.ts
|
|
6
|
+
var SimaGames = core.registerPlugin("SimaGames");
|
|
7
|
+
var defaultDriver = {
|
|
8
|
+
isSupported() {
|
|
9
|
+
return typeof window !== "undefined" && core.Capacitor.isNativePlatform() && core.Capacitor.isPluginAvailable("SimaGames");
|
|
10
|
+
},
|
|
11
|
+
getPlatform() {
|
|
12
|
+
const p = core.Capacitor.getPlatform();
|
|
13
|
+
if (p === "android" || p === "ios") return p;
|
|
14
|
+
return "web";
|
|
15
|
+
},
|
|
16
|
+
isAuthenticated: () => SimaGames.isAuthenticated(),
|
|
17
|
+
signIn: () => SimaGames.signIn(),
|
|
18
|
+
submitScore: (leaderboardId, score) => SimaGames.submitScore({ leaderboardId, score }),
|
|
19
|
+
showLeaderboard: (leaderboardId, timeSpan) => SimaGames.showLeaderboard({ leaderboardId, timeSpan }),
|
|
20
|
+
unlockAchievement: (achievementId) => SimaGames.unlockAchievement({ achievementId })
|
|
21
|
+
};
|
|
22
|
+
function createGamesClient(config = {}) {
|
|
23
|
+
const driver = config.driver ?? defaultDriver;
|
|
24
|
+
function resolveId(keyOrId, table) {
|
|
25
|
+
const entry = table?.[keyOrId];
|
|
26
|
+
if (entry) {
|
|
27
|
+
const platform = driver.getPlatform();
|
|
28
|
+
const id = platform === "android" ? entry.android : platform === "ios" ? entry.ios : void 0;
|
|
29
|
+
return id?.trim() || null;
|
|
30
|
+
}
|
|
31
|
+
const direct = keyOrId.trim();
|
|
32
|
+
return direct.length > 0 ? direct : null;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
isSupported: () => driver.isSupported(),
|
|
36
|
+
async isAuthenticated() {
|
|
37
|
+
if (!driver.isSupported()) return false;
|
|
38
|
+
try {
|
|
39
|
+
const res = await driver.isAuthenticated();
|
|
40
|
+
return Boolean(res?.authenticated);
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
async signIn() {
|
|
46
|
+
if (!driver.isSupported()) return false;
|
|
47
|
+
try {
|
|
48
|
+
const res = await driver.signIn();
|
|
49
|
+
return Boolean(res?.authenticated);
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
async submitScore(leaderboardKeyOrId, score) {
|
|
55
|
+
if (!driver.isSupported() || !Number.isFinite(score)) return false;
|
|
56
|
+
const leaderboardId = resolveId(leaderboardKeyOrId, config.leaderboards);
|
|
57
|
+
if (!leaderboardId) return false;
|
|
58
|
+
try {
|
|
59
|
+
const res = await driver.submitScore(leaderboardId, Math.round(score));
|
|
60
|
+
return Boolean(res?.submitted);
|
|
61
|
+
} catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
async showLeaderboard(leaderboardKeyOrId, timeSpan = "allTime") {
|
|
66
|
+
if (!driver.isSupported()) return false;
|
|
67
|
+
const leaderboardId = resolveId(leaderboardKeyOrId, config.leaderboards);
|
|
68
|
+
if (!leaderboardId) return false;
|
|
69
|
+
try {
|
|
70
|
+
const authed = await driver.isAuthenticated();
|
|
71
|
+
if (!authed?.authenticated) {
|
|
72
|
+
const signedIn = await driver.signIn();
|
|
73
|
+
if (!signedIn?.authenticated) return false;
|
|
74
|
+
}
|
|
75
|
+
const res = await driver.showLeaderboard(leaderboardId, timeSpan);
|
|
76
|
+
return Boolean(res?.shown);
|
|
77
|
+
} catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
async unlockAchievement(achievementKeyOrId) {
|
|
82
|
+
if (!driver.isSupported()) return false;
|
|
83
|
+
const achievementId = resolveId(achievementKeyOrId, config.achievements);
|
|
84
|
+
if (!achievementId) return false;
|
|
85
|
+
try {
|
|
86
|
+
const res = await driver.unlockAchievement(achievementId);
|
|
87
|
+
return Boolean(res?.unlocked);
|
|
88
|
+
} catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
exports.SimaGames = SimaGames;
|
|
96
|
+
exports.createGamesClient = createGamesClient;
|
|
97
|
+
//# sourceMappingURL=games.cjs.map
|
|
98
|
+
//# sourceMappingURL=games.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"s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AA,GAAM,MAAM,MAAA,CAAO,iBAAA,CAAkB,aAAa,CAAA;AACxD,QAAA,OAAO,OAAA,CAAQ,KAAK,QAAQ,CAAA;AAAA,MAC9B,CAAA,CAAA,MAAQ;AACN,QAAA,OAAO,KAAA;AAAA,MACT;AAAA,IACF;AAAA,GACF;AACF","file":"games.cjs","sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\n\nexport type LeaderboardTimeSpan = 'daily' | 'weekly' | 'allTime';\n\nexport interface PlatformIdMap {\n android?: string;\n ios?: string;\n}\n\nexport interface SimaGamesNativePlugin {\n isAuthenticated(): Promise<{ authenticated: boolean }>;\n signIn(): Promise<{ authenticated: boolean }>;\n submitScore(options: { leaderboardId: string; score: number }): Promise<{ submitted: boolean }>;\n showLeaderboard(options: {\n leaderboardId: string;\n timeSpan?: LeaderboardTimeSpan;\n }): Promise<{ shown: boolean }>;\n unlockAchievement(options: { achievementId: string }): Promise<{ unlocked: boolean }>;\n}\n\nexport const SimaGames = registerPlugin<SimaGamesNativePlugin>('SimaGames');\n\nexport interface GamesDriver {\n isSupported(): boolean;\n getPlatform(): 'android' | 'ios' | 'web';\n isAuthenticated(): Promise<{ authenticated: boolean }>;\n signIn(): Promise<{ authenticated: boolean }>;\n submitScore(leaderboardId: string, score: number): Promise<{ submitted: boolean }>;\n showLeaderboard(\n leaderboardId: string,\n timeSpan: LeaderboardTimeSpan,\n ): Promise<{ shown: boolean }>;\n unlockAchievement(achievementId: string): Promise<{ unlocked: boolean }>;\n}\n\nexport interface GamesConfig {\n /** Named leaderboards mapped to Android (Play Games) and iOS (Game Center) IDs. */\n leaderboards?: Record<string, PlatformIdMap>;\n /** Named achievements mapped to Android and iOS IDs. */\n achievements?: Record<string, PlatformIdMap>;\n /** Optional custom driver (primarily for testing). */\n driver?: GamesDriver;\n}\n\nexport interface GamesClient {\n isSupported(): boolean;\n isAuthenticated(): Promise<boolean>;\n signIn(): Promise<boolean>;\n submitScore(leaderboardKeyOrId: string, score: number): Promise<boolean>;\n showLeaderboard(\n leaderboardKeyOrId: string,\n timeSpan?: LeaderboardTimeSpan,\n ): Promise<boolean>;\n unlockAchievement(achievementKeyOrId: string): Promise<boolean>;\n}\n\nconst defaultDriver: GamesDriver = {\n isSupported(): boolean {\n return (\n typeof window !== 'undefined' &&\n Capacitor.isNativePlatform() &&\n Capacitor.isPluginAvailable('SimaGames')\n );\n },\n getPlatform(): 'android' | 'ios' | 'web' {\n const p = Capacitor.getPlatform();\n if (p === 'android' || p === 'ios') return p;\n return 'web';\n },\n isAuthenticated: () => SimaGames.isAuthenticated(),\n signIn: () => SimaGames.signIn(),\n submitScore: (leaderboardId, score) => SimaGames.submitScore({ leaderboardId, score }),\n showLeaderboard: (leaderboardId, timeSpan) =>\n SimaGames.showLeaderboard({ leaderboardId, timeSpan }),\n unlockAchievement: (achievementId) => SimaGames.unlockAchievement({ achievementId }),\n};\n\n/**\n * Opt-in Play Games Services v2 (Android) + Game Center (iOS) client.\n * Never throws into gameplay flows and safely no-ops on web/SSR or when unconfigured.\n */\nexport function createGamesClient(config: GamesConfig = {}): GamesClient {\n const driver = config.driver ?? defaultDriver;\n\n function resolveId(\n keyOrId: string,\n table?: Record<string, PlatformIdMap>,\n ): string | null {\n const entry = table?.[keyOrId];\n if (entry) {\n const platform = driver.getPlatform();\n const id = platform === 'android' ? entry.android : platform === 'ios' ? entry.ios : undefined;\n return id?.trim() || null;\n }\n const direct = keyOrId.trim();\n return direct.length > 0 ? direct : null;\n }\n\n return {\n isSupported: () => driver.isSupported(),\n\n async isAuthenticated(): Promise<boolean> {\n if (!driver.isSupported()) return false;\n try {\n const res = await driver.isAuthenticated();\n return Boolean(res?.authenticated);\n } catch {\n return false;\n }\n },\n\n async signIn(): Promise<boolean> {\n if (!driver.isSupported()) return false;\n try {\n const res = await driver.signIn();\n return Boolean(res?.authenticated);\n } catch {\n return false;\n }\n },\n\n async submitScore(leaderboardKeyOrId: string, score: number): Promise<boolean> {\n if (!driver.isSupported() || !Number.isFinite(score)) return false;\n const leaderboardId = resolveId(leaderboardKeyOrId, config.leaderboards);\n if (!leaderboardId) return false;\n try {\n const res = await driver.submitScore(leaderboardId, Math.round(score));\n return Boolean(res?.submitted);\n } catch {\n return false;\n }\n },\n\n async showLeaderboard(\n leaderboardKeyOrId: string,\n timeSpan: LeaderboardTimeSpan = 'allTime',\n ): Promise<boolean> {\n if (!driver.isSupported()) return false;\n const leaderboardId = resolveId(leaderboardKeyOrId, config.leaderboards);\n if (!leaderboardId) return false;\n try {\n const authed = await driver.isAuthenticated();\n if (!authed?.authenticated) {\n const signedIn = await driver.signIn();\n if (!signedIn?.authenticated) return false;\n }\n const res = await driver.showLeaderboard(leaderboardId, timeSpan);\n return Boolean(res?.shown);\n } catch {\n return false;\n }\n },\n\n async unlockAchievement(achievementKeyOrId: string): Promise<boolean> {\n if (!driver.isSupported()) return false;\n const achievementId = resolveId(achievementKeyOrId, config.achievements);\n if (!achievementId) return false;\n try {\n const res = await driver.unlockAchievement(achievementId);\n return Boolean(res?.unlocked);\n } catch {\n return false;\n }\n },\n };\n}\n"]}
|
package/dist/games.d.cts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
type LeaderboardTimeSpan = 'daily' | 'weekly' | 'allTime';
|
|
2
|
+
interface PlatformIdMap {
|
|
3
|
+
android?: string;
|
|
4
|
+
ios?: string;
|
|
5
|
+
}
|
|
6
|
+
interface SimaGamesNativePlugin {
|
|
7
|
+
isAuthenticated(): Promise<{
|
|
8
|
+
authenticated: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
signIn(): Promise<{
|
|
11
|
+
authenticated: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
submitScore(options: {
|
|
14
|
+
leaderboardId: string;
|
|
15
|
+
score: number;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
submitted: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
showLeaderboard(options: {
|
|
20
|
+
leaderboardId: string;
|
|
21
|
+
timeSpan?: LeaderboardTimeSpan;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
shown: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
unlockAchievement(options: {
|
|
26
|
+
achievementId: string;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
unlocked: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
declare const SimaGames: SimaGamesNativePlugin;
|
|
32
|
+
interface GamesDriver {
|
|
33
|
+
isSupported(): boolean;
|
|
34
|
+
getPlatform(): 'android' | 'ios' | 'web';
|
|
35
|
+
isAuthenticated(): Promise<{
|
|
36
|
+
authenticated: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
signIn(): Promise<{
|
|
39
|
+
authenticated: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
submitScore(leaderboardId: string, score: number): Promise<{
|
|
42
|
+
submitted: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
showLeaderboard(leaderboardId: string, timeSpan: LeaderboardTimeSpan): Promise<{
|
|
45
|
+
shown: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
unlockAchievement(achievementId: string): Promise<{
|
|
48
|
+
unlocked: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
interface GamesConfig {
|
|
52
|
+
/** Named leaderboards mapped to Android (Play Games) and iOS (Game Center) IDs. */
|
|
53
|
+
leaderboards?: Record<string, PlatformIdMap>;
|
|
54
|
+
/** Named achievements mapped to Android and iOS IDs. */
|
|
55
|
+
achievements?: Record<string, PlatformIdMap>;
|
|
56
|
+
/** Optional custom driver (primarily for testing). */
|
|
57
|
+
driver?: GamesDriver;
|
|
58
|
+
}
|
|
59
|
+
interface GamesClient {
|
|
60
|
+
isSupported(): boolean;
|
|
61
|
+
isAuthenticated(): Promise<boolean>;
|
|
62
|
+
signIn(): Promise<boolean>;
|
|
63
|
+
submitScore(leaderboardKeyOrId: string, score: number): Promise<boolean>;
|
|
64
|
+
showLeaderboard(leaderboardKeyOrId: string, timeSpan?: LeaderboardTimeSpan): Promise<boolean>;
|
|
65
|
+
unlockAchievement(achievementKeyOrId: string): Promise<boolean>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Opt-in Play Games Services v2 (Android) + Game Center (iOS) client.
|
|
69
|
+
* Never throws into gameplay flows and safely no-ops on web/SSR or when unconfigured.
|
|
70
|
+
*/
|
|
71
|
+
declare function createGamesClient(config?: GamesConfig): GamesClient;
|
|
72
|
+
|
|
73
|
+
export { type GamesClient, type GamesConfig, type GamesDriver, type LeaderboardTimeSpan, type PlatformIdMap, SimaGames, type SimaGamesNativePlugin, createGamesClient };
|
package/dist/games.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
type LeaderboardTimeSpan = 'daily' | 'weekly' | 'allTime';
|
|
2
|
+
interface PlatformIdMap {
|
|
3
|
+
android?: string;
|
|
4
|
+
ios?: string;
|
|
5
|
+
}
|
|
6
|
+
interface SimaGamesNativePlugin {
|
|
7
|
+
isAuthenticated(): Promise<{
|
|
8
|
+
authenticated: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
signIn(): Promise<{
|
|
11
|
+
authenticated: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
submitScore(options: {
|
|
14
|
+
leaderboardId: string;
|
|
15
|
+
score: number;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
submitted: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
showLeaderboard(options: {
|
|
20
|
+
leaderboardId: string;
|
|
21
|
+
timeSpan?: LeaderboardTimeSpan;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
shown: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
unlockAchievement(options: {
|
|
26
|
+
achievementId: string;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
unlocked: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
declare const SimaGames: SimaGamesNativePlugin;
|
|
32
|
+
interface GamesDriver {
|
|
33
|
+
isSupported(): boolean;
|
|
34
|
+
getPlatform(): 'android' | 'ios' | 'web';
|
|
35
|
+
isAuthenticated(): Promise<{
|
|
36
|
+
authenticated: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
signIn(): Promise<{
|
|
39
|
+
authenticated: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
submitScore(leaderboardId: string, score: number): Promise<{
|
|
42
|
+
submitted: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
showLeaderboard(leaderboardId: string, timeSpan: LeaderboardTimeSpan): Promise<{
|
|
45
|
+
shown: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
unlockAchievement(achievementId: string): Promise<{
|
|
48
|
+
unlocked: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
interface GamesConfig {
|
|
52
|
+
/** Named leaderboards mapped to Android (Play Games) and iOS (Game Center) IDs. */
|
|
53
|
+
leaderboards?: Record<string, PlatformIdMap>;
|
|
54
|
+
/** Named achievements mapped to Android and iOS IDs. */
|
|
55
|
+
achievements?: Record<string, PlatformIdMap>;
|
|
56
|
+
/** Optional custom driver (primarily for testing). */
|
|
57
|
+
driver?: GamesDriver;
|
|
58
|
+
}
|
|
59
|
+
interface GamesClient {
|
|
60
|
+
isSupported(): boolean;
|
|
61
|
+
isAuthenticated(): Promise<boolean>;
|
|
62
|
+
signIn(): Promise<boolean>;
|
|
63
|
+
submitScore(leaderboardKeyOrId: string, score: number): Promise<boolean>;
|
|
64
|
+
showLeaderboard(leaderboardKeyOrId: string, timeSpan?: LeaderboardTimeSpan): Promise<boolean>;
|
|
65
|
+
unlockAchievement(achievementKeyOrId: string): Promise<boolean>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Opt-in Play Games Services v2 (Android) + Game Center (iOS) client.
|
|
69
|
+
* Never throws into gameplay flows and safely no-ops on web/SSR or when unconfigured.
|
|
70
|
+
*/
|
|
71
|
+
declare function createGamesClient(config?: GamesConfig): GamesClient;
|
|
72
|
+
|
|
73
|
+
export { type GamesClient, type GamesConfig, type GamesDriver, type LeaderboardTimeSpan, type PlatformIdMap, SimaGames, type SimaGamesNativePlugin, createGamesClient };
|
package/dist/games.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { registerPlugin, Capacitor } from '@capacitor/core';
|
|
2
|
+
|
|
3
|
+
// src/games.ts
|
|
4
|
+
var SimaGames = registerPlugin("SimaGames");
|
|
5
|
+
var defaultDriver = {
|
|
6
|
+
isSupported() {
|
|
7
|
+
return typeof window !== "undefined" && Capacitor.isNativePlatform() && Capacitor.isPluginAvailable("SimaGames");
|
|
8
|
+
},
|
|
9
|
+
getPlatform() {
|
|
10
|
+
const p = Capacitor.getPlatform();
|
|
11
|
+
if (p === "android" || p === "ios") return p;
|
|
12
|
+
return "web";
|
|
13
|
+
},
|
|
14
|
+
isAuthenticated: () => SimaGames.isAuthenticated(),
|
|
15
|
+
signIn: () => SimaGames.signIn(),
|
|
16
|
+
submitScore: (leaderboardId, score) => SimaGames.submitScore({ leaderboardId, score }),
|
|
17
|
+
showLeaderboard: (leaderboardId, timeSpan) => SimaGames.showLeaderboard({ leaderboardId, timeSpan }),
|
|
18
|
+
unlockAchievement: (achievementId) => SimaGames.unlockAchievement({ achievementId })
|
|
19
|
+
};
|
|
20
|
+
function createGamesClient(config = {}) {
|
|
21
|
+
const driver = config.driver ?? defaultDriver;
|
|
22
|
+
function resolveId(keyOrId, table) {
|
|
23
|
+
const entry = table?.[keyOrId];
|
|
24
|
+
if (entry) {
|
|
25
|
+
const platform = driver.getPlatform();
|
|
26
|
+
const id = platform === "android" ? entry.android : platform === "ios" ? entry.ios : void 0;
|
|
27
|
+
return id?.trim() || null;
|
|
28
|
+
}
|
|
29
|
+
const direct = keyOrId.trim();
|
|
30
|
+
return direct.length > 0 ? direct : null;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
isSupported: () => driver.isSupported(),
|
|
34
|
+
async isAuthenticated() {
|
|
35
|
+
if (!driver.isSupported()) return false;
|
|
36
|
+
try {
|
|
37
|
+
const res = await driver.isAuthenticated();
|
|
38
|
+
return Boolean(res?.authenticated);
|
|
39
|
+
} catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
async signIn() {
|
|
44
|
+
if (!driver.isSupported()) return false;
|
|
45
|
+
try {
|
|
46
|
+
const res = await driver.signIn();
|
|
47
|
+
return Boolean(res?.authenticated);
|
|
48
|
+
} catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
async submitScore(leaderboardKeyOrId, score) {
|
|
53
|
+
if (!driver.isSupported() || !Number.isFinite(score)) return false;
|
|
54
|
+
const leaderboardId = resolveId(leaderboardKeyOrId, config.leaderboards);
|
|
55
|
+
if (!leaderboardId) return false;
|
|
56
|
+
try {
|
|
57
|
+
const res = await driver.submitScore(leaderboardId, Math.round(score));
|
|
58
|
+
return Boolean(res?.submitted);
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
async showLeaderboard(leaderboardKeyOrId, timeSpan = "allTime") {
|
|
64
|
+
if (!driver.isSupported()) return false;
|
|
65
|
+
const leaderboardId = resolveId(leaderboardKeyOrId, config.leaderboards);
|
|
66
|
+
if (!leaderboardId) return false;
|
|
67
|
+
try {
|
|
68
|
+
const authed = await driver.isAuthenticated();
|
|
69
|
+
if (!authed?.authenticated) {
|
|
70
|
+
const signedIn = await driver.signIn();
|
|
71
|
+
if (!signedIn?.authenticated) return false;
|
|
72
|
+
}
|
|
73
|
+
const res = await driver.showLeaderboard(leaderboardId, timeSpan);
|
|
74
|
+
return Boolean(res?.shown);
|
|
75
|
+
} catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
async unlockAchievement(achievementKeyOrId) {
|
|
80
|
+
if (!driver.isSupported()) return false;
|
|
81
|
+
const achievementId = resolveId(achievementKeyOrId, config.achievements);
|
|
82
|
+
if (!achievementId) return false;
|
|
83
|
+
try {
|
|
84
|
+
const res = await driver.unlockAchievement(achievementId);
|
|
85
|
+
return Boolean(res?.unlocked);
|
|
86
|
+
} catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { SimaGames, createGamesClient };
|
|
94
|
+
//# sourceMappingURL=games.js.map
|
|
95
|
+
//# sourceMappingURL=games.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/games.ts"],"names":[],"mappings":";;;AAoBO,IAAM,SAAA,GAAY,eAAsC,WAAW;AAoC1E,IAAM,aAAA,GAA6B;AAAA,EACjC,WAAA,GAAuB;AACrB,IAAA,OACE,OAAO,WAAW,WAAA,IAClB,SAAA,CAAU,kBAAiB,IAC3B,SAAA,CAAU,kBAAkB,WAAW,CAAA;AAAA,EAE3C,CAAA;AAAA,EACA,WAAA,GAAyC;AACvC,IAAA,MAAM,CAAA,GAAI,UAAU,WAAA,EAAY;AAChC,IAAA,IAAI,CAAA,KAAM,SAAA,IAAa,CAAA,KAAM,KAAA,EAAO,OAAO,CAAA;AAC3C,IAAA,OAAO,KAAA;AAAA,EACT,CAAA;AAAA,EACA,eAAA,EAAiB,MAAM,SAAA,CAAU,eAAA,EAAgB;AAAA,EACjD,MAAA,EAAQ,MAAM,SAAA,CAAU,MAAA,EAAO;AAAA,EAC/B,WAAA,EAAa,CAAC,aAAA,EAAe,KAAA,KAAU,UAAU,WAAA,CAAY,EAAE,aAAA,EAAe,KAAA,EAAO,CAAA;AAAA,EACrF,eAAA,EAAiB,CAAC,aAAA,EAAe,QAAA,KAC/B,UAAU,eAAA,CAAgB,EAAE,aAAA,EAAe,QAAA,EAAU,CAAA;AAAA,EACvD,mBAAmB,CAAC,aAAA,KAAkB,UAAU,iBAAA,CAAkB,EAAE,eAAe;AACrF,CAAA;AAMO,SAAS,iBAAA,CAAkB,MAAA,GAAsB,EAAC,EAAgB;AACvE,EAAA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A,MACT;AAAA,IACF,CAAA;AAAA,IAEA,MAAM,kBAAkB,kBAAA,EAA8C;AACpE,MAAA,IAAI,CAAC,MAAA,CAAO,WAAA,EAAY,EAAG,OAAO,KAAA;AAClC,MAAA,MAAM,aAAA,GAAgB,SAAA,CAAU,kBAAA,EAAoB,MAAA,CAAO,YAAY,CAAA;AACvE,MAAA,IAAI,CAAC,eAAe,OAAO,KAAA;AAC3B,MAAA,IAAI;AACF,QAAA,MAAM,GAAA,GAAM,MAAM,MAAA,CAAO,iBAAA,CAAkB,aAAa,CAAA;AACxD,QAAA,OAAO,OAAA,CAAQ,KAAK,QAAQ,CAAA;AAAA,MAC9B,CAAA,CAAA,MAAQ;AACN,QAAA,OAAO,KAAA;AAAA,MACT;AAAA,IACF;AAAA,GACF;AACF","file":"games.js","sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\n\nexport type LeaderboardTimeSpan = 'daily' | 'weekly' | 'allTime';\n\nexport interface PlatformIdMap {\n android?: string;\n ios?: string;\n}\n\nexport interface SimaGamesNativePlugin {\n isAuthenticated(): Promise<{ authenticated: boolean }>;\n signIn(): Promise<{ authenticated: boolean }>;\n submitScore(options: { leaderboardId: string; score: number }): Promise<{ submitted: boolean }>;\n showLeaderboard(options: {\n leaderboardId: string;\n timeSpan?: LeaderboardTimeSpan;\n }): Promise<{ shown: boolean }>;\n unlockAchievement(options: { achievementId: string }): Promise<{ unlocked: boolean }>;\n}\n\nexport const SimaGames = registerPlugin<SimaGamesNativePlugin>('SimaGames');\n\nexport interface GamesDriver {\n isSupported(): boolean;\n getPlatform(): 'android' | 'ios' | 'web';\n isAuthenticated(): Promise<{ authenticated: boolean }>;\n signIn(): Promise<{ authenticated: boolean }>;\n submitScore(leaderboardId: string, score: number): Promise<{ submitted: boolean }>;\n showLeaderboard(\n leaderboardId: string,\n timeSpan: LeaderboardTimeSpan,\n ): Promise<{ shown: boolean }>;\n unlockAchievement(achievementId: string): Promise<{ unlocked: boolean }>;\n}\n\nexport interface GamesConfig {\n /** Named leaderboards mapped to Android (Play Games) and iOS (Game Center) IDs. */\n leaderboards?: Record<string, PlatformIdMap>;\n /** Named achievements mapped to Android and iOS IDs. */\n achievements?: Record<string, PlatformIdMap>;\n /** Optional custom driver (primarily for testing). */\n driver?: GamesDriver;\n}\n\nexport interface GamesClient {\n isSupported(): boolean;\n isAuthenticated(): Promise<boolean>;\n signIn(): Promise<boolean>;\n submitScore(leaderboardKeyOrId: string, score: number): Promise<boolean>;\n showLeaderboard(\n leaderboardKeyOrId: string,\n timeSpan?: LeaderboardTimeSpan,\n ): Promise<boolean>;\n unlockAchievement(achievementKeyOrId: string): Promise<boolean>;\n}\n\nconst defaultDriver: GamesDriver = {\n isSupported(): boolean {\n return (\n typeof window !== 'undefined' &&\n Capacitor.isNativePlatform() &&\n Capacitor.isPluginAvailable('SimaGames')\n );\n },\n getPlatform(): 'android' | 'ios' | 'web' {\n const p = Capacitor.getPlatform();\n if (p === 'android' || p === 'ios') return p;\n return 'web';\n },\n isAuthenticated: () => SimaGames.isAuthenticated(),\n signIn: () => SimaGames.signIn(),\n submitScore: (leaderboardId, score) => SimaGames.submitScore({ leaderboardId, score }),\n showLeaderboard: (leaderboardId, timeSpan) =>\n SimaGames.showLeaderboard({ leaderboardId, timeSpan }),\n unlockAchievement: (achievementId) => SimaGames.unlockAchievement({ achievementId }),\n};\n\n/**\n * Opt-in Play Games Services v2 (Android) + Game Center (iOS) client.\n * Never throws into gameplay flows and safely no-ops on web/SSR or when unconfigured.\n */\nexport function createGamesClient(config: GamesConfig = {}): GamesClient {\n const driver = config.driver ?? defaultDriver;\n\n function resolveId(\n keyOrId: string,\n table?: Record<string, PlatformIdMap>,\n ): string | null {\n const entry = table?.[keyOrId];\n if (entry) {\n const platform = driver.getPlatform();\n const id = platform === 'android' ? entry.android : platform === 'ios' ? entry.ios : undefined;\n return id?.trim() || null;\n }\n const direct = keyOrId.trim();\n return direct.length > 0 ? direct : null;\n }\n\n return {\n isSupported: () => driver.isSupported(),\n\n async isAuthenticated(): Promise<boolean> {\n if (!driver.isSupported()) return false;\n try {\n const res = await driver.isAuthenticated();\n return Boolean(res?.authenticated);\n } catch {\n return false;\n }\n },\n\n async signIn(): Promise<boolean> {\n if (!driver.isSupported()) return false;\n try {\n const res = await driver.signIn();\n return Boolean(res?.authenticated);\n } catch {\n return false;\n }\n },\n\n async submitScore(leaderboardKeyOrId: string, score: number): Promise<boolean> {\n if (!driver.isSupported() || !Number.isFinite(score)) return false;\n const leaderboardId = resolveId(leaderboardKeyOrId, config.leaderboards);\n if (!leaderboardId) return false;\n try {\n const res = await driver.submitScore(leaderboardId, Math.round(score));\n return Boolean(res?.submitted);\n } catch {\n return false;\n }\n },\n\n async showLeaderboard(\n leaderboardKeyOrId: string,\n timeSpan: LeaderboardTimeSpan = 'allTime',\n ): Promise<boolean> {\n if (!driver.isSupported()) return false;\n const leaderboardId = resolveId(leaderboardKeyOrId, config.leaderboards);\n if (!leaderboardId) return false;\n try {\n const authed = await driver.isAuthenticated();\n if (!authed?.authenticated) {\n const signedIn = await driver.signIn();\n if (!signedIn?.authenticated) return false;\n }\n const res = await driver.showLeaderboard(leaderboardId, timeSpan);\n return Boolean(res?.shown);\n } catch {\n return false;\n }\n },\n\n async unlockAchievement(achievementKeyOrId: string): Promise<boolean> {\n if (!driver.isSupported()) return false;\n const achievementId = resolveId(achievementKeyOrId, config.achievements);\n if (!achievementId) return false;\n try {\n const res = await driver.unlockAchievement(achievementId);\n return Boolean(res?.unlocked);\n } catch {\n return false;\n }\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import AppTrackingTransparency
|
|
4
|
+
|
|
5
|
+
@objc(SimaAttPlugin)
|
|
6
|
+
public class SimaAttPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
7
|
+
public let identifier = "SimaAttPlugin"
|
|
8
|
+
public let jsName = "SimaAtt"
|
|
9
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
10
|
+
CAPPluginMethod(name: "getStatus", returnType: CAPPluginReturnPromise),
|
|
11
|
+
CAPPluginMethod(name: "requestAuthorization", returnType: CAPPluginReturnPromise)
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
private func mapStatus(_ status: ATTrackingManager.AuthorizationStatus) -> String {
|
|
15
|
+
switch status {
|
|
16
|
+
case .authorized:
|
|
17
|
+
return "authorized"
|
|
18
|
+
case .denied:
|
|
19
|
+
return "denied"
|
|
20
|
+
case .restricted:
|
|
21
|
+
return "restricted"
|
|
22
|
+
case .notDetermined:
|
|
23
|
+
return "not_determined"
|
|
24
|
+
@unknown default:
|
|
25
|
+
return "not_determined"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@objc func getStatus(_ call: CAPPluginCall) {
|
|
30
|
+
let status = mapStatus(ATTrackingManager.trackingAuthorizationStatus)
|
|
31
|
+
call.resolve(["status": status])
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@objc func requestAuthorization(_ call: CAPPluginCall) {
|
|
35
|
+
DispatchQueue.main.async {
|
|
36
|
+
ATTrackingManager.requestTrackingAuthorization { status in
|
|
37
|
+
call.resolve(["status": self.mapStatus(status)])
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import GameKit
|
|
4
|
+
import UIKit
|
|
5
|
+
|
|
6
|
+
@objc(SimaGamesPlugin)
|
|
7
|
+
public class SimaGamesPlugin: CAPPlugin, CAPBridgedPlugin, GKGameCenterControllerDelegate {
|
|
8
|
+
public let identifier = "SimaGamesPlugin"
|
|
9
|
+
public let jsName = "SimaGames"
|
|
10
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
11
|
+
CAPPluginMethod(name: "isAuthenticated", returnType: CAPPluginReturnPromise),
|
|
12
|
+
CAPPluginMethod(name: "signIn", returnType: CAPPluginReturnPromise),
|
|
13
|
+
CAPPluginMethod(name: "submitScore", returnType: CAPPluginReturnPromise),
|
|
14
|
+
CAPPluginMethod(name: "showLeaderboard", returnType: CAPPluginReturnPromise),
|
|
15
|
+
CAPPluginMethod(name: "unlockAchievement", returnType: CAPPluginReturnPromise)
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
private var pendingLeaderboardCall: CAPPluginCall?
|
|
19
|
+
|
|
20
|
+
@objc func isAuthenticated(_ call: CAPPluginCall) {
|
|
21
|
+
call.resolve(["authenticated": GKLocalPlayer.local.isAuthenticated])
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@objc func signIn(_ call: CAPPluginCall) {
|
|
25
|
+
DispatchQueue.main.async {
|
|
26
|
+
let player = GKLocalPlayer.local
|
|
27
|
+
if player.isAuthenticated {
|
|
28
|
+
call.resolve(["authenticated": true])
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var resolved = false
|
|
33
|
+
player.authenticateHandler = { [weak self] viewController, error in
|
|
34
|
+
if let vc = viewController {
|
|
35
|
+
self?.bridge?.viewController?.present(vc, animated: true)
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
if !resolved {
|
|
39
|
+
resolved = true
|
|
40
|
+
if let error = error {
|
|
41
|
+
call.resolve(["authenticated": false, "error": error.localizedDescription])
|
|
42
|
+
} else {
|
|
43
|
+
call.resolve(["authenticated": player.isAuthenticated])
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@objc func submitScore(_ call: CAPPluginCall) {
|
|
51
|
+
guard let leaderboardId = call.getString("leaderboardId")?.trimmingCharacters(in: .whitespacesAndNewlines),
|
|
52
|
+
!leaderboardId.isEmpty,
|
|
53
|
+
let scoreDouble = call.getDouble("score"),
|
|
54
|
+
scoreDouble.isFinite else {
|
|
55
|
+
call.reject("leaderboardId and finite numeric score are required.", "INVALID_ARGUMENT")
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
guard GKLocalPlayer.local.isAuthenticated else {
|
|
60
|
+
call.resolve(["submitted": false])
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let scoreInt = Int(scoreDouble.rounded())
|
|
65
|
+
GKLeaderboard.submitScore(
|
|
66
|
+
scoreInt,
|
|
67
|
+
context: 0,
|
|
68
|
+
player: GKLocalPlayer.local,
|
|
69
|
+
leaderboardIDs: [leaderboardId]
|
|
70
|
+
) { error in
|
|
71
|
+
if let error = error {
|
|
72
|
+
call.reject("Failed to submit Game Center score.", "SUBMIT_ERROR", error)
|
|
73
|
+
} else {
|
|
74
|
+
call.resolve(["submitted": true])
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@objc func showLeaderboard(_ call: CAPPluginCall) {
|
|
80
|
+
guard let leaderboardId = call.getString("leaderboardId")?.trimmingCharacters(in: .whitespacesAndNewlines),
|
|
81
|
+
!leaderboardId.isEmpty else {
|
|
82
|
+
call.reject("leaderboardId is required.", "INVALID_ARGUMENT")
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let timeSpan = call.getString("timeSpan") ?? "allTime"
|
|
87
|
+
let scope: GKLeaderboard.TimeScope
|
|
88
|
+
switch timeSpan.lowercased() {
|
|
89
|
+
case "daily":
|
|
90
|
+
scope = .today
|
|
91
|
+
case "weekly":
|
|
92
|
+
scope = .week
|
|
93
|
+
default:
|
|
94
|
+
scope = .allTime
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
DispatchQueue.main.async {
|
|
98
|
+
guard let presenter = self.bridge?.viewController else {
|
|
99
|
+
call.reject("Unable to locate root view controller.", "NO_VIEW_CONTROLLER")
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
self.pendingLeaderboardCall = call
|
|
103
|
+
let gcVC = GKGameCenterViewController(
|
|
104
|
+
leaderboardID: leaderboardId,
|
|
105
|
+
playerScope: .global,
|
|
106
|
+
timeScope: scope
|
|
107
|
+
)
|
|
108
|
+
gcVC.gameCenterDelegate = self
|
|
109
|
+
presenter.present(gcVC, animated: true)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@objc func unlockAchievement(_ call: CAPPluginCall) {
|
|
114
|
+
guard let achievementId = call.getString("achievementId")?.trimmingCharacters(in: .whitespacesAndNewlines),
|
|
115
|
+
!achievementId.isEmpty else {
|
|
116
|
+
call.reject("achievementId is required.", "INVALID_ARGUMENT")
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
guard GKLocalPlayer.local.isAuthenticated else {
|
|
121
|
+
call.resolve(["unlocked": false])
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let achievement = GKAchievement(identifier: achievementId)
|
|
126
|
+
achievement.percentComplete = 100.0
|
|
127
|
+
achievement.showsCompletionBanner = true
|
|
128
|
+
GKAchievement.report([achievement]) { error in
|
|
129
|
+
if let error = error {
|
|
130
|
+
call.reject("Failed to unlock achievement.", "ACHIEVEMENT_ERROR", error)
|
|
131
|
+
} else {
|
|
132
|
+
call.resolve(["unlocked": true])
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public func gameCenterViewControllerDidFinish(_ gameCenterViewController: GKGameCenterViewController) {
|
|
138
|
+
gameCenterViewController.dismiss(animated: true) {
|
|
139
|
+
if let call = self.pendingLeaderboardCall {
|
|
140
|
+
self.pendingLeaderboardCall = nil
|
|
141
|
+
call.resolve(["shown": true])
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cond/simasdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -68,6 +68,16 @@
|
|
|
68
68
|
"types": "./dist/ads.d.ts",
|
|
69
69
|
"import": "./dist/ads.js",
|
|
70
70
|
"require": "./dist/ads.cjs"
|
|
71
|
+
},
|
|
72
|
+
"./games": {
|
|
73
|
+
"types": "./dist/games.d.ts",
|
|
74
|
+
"import": "./dist/games.js",
|
|
75
|
+
"require": "./dist/games.cjs"
|
|
76
|
+
},
|
|
77
|
+
"./att": {
|
|
78
|
+
"types": "./dist/att.d.ts",
|
|
79
|
+
"import": "./dist/att.js",
|
|
80
|
+
"require": "./dist/att.cjs"
|
|
71
81
|
}
|
|
72
82
|
},
|
|
73
83
|
"files": [
|