@cond/simasdk 0.0.0-stage → 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.
Files changed (85) hide show
  1. package/CondSimasdk.podspec +18 -0
  2. package/Package.swift +31 -0
  3. package/README.md +508 -2
  4. package/android/build.gradle +63 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/simasdk/SimaFirebasePlugin.java +139 -0
  7. package/android/src/main/java/com/simasdk/SimaGamesPlugin.java +235 -0
  8. package/android/src/main/java/com/simasdk/SimaHapticsPlugin.java +101 -0
  9. package/android/src/main/java/com/simasdk/SimaReviewPlugin.java +48 -0
  10. package/android/src/main/java/com/simasdk/SimaStoragePlugin.java +79 -0
  11. package/dist/ads.cjs +214 -0
  12. package/dist/ads.cjs.map +1 -0
  13. package/dist/ads.d.cts +98 -0
  14. package/dist/ads.d.ts +98 -0
  15. package/dist/ads.js +211 -0
  16. package/dist/ads.js.map +1 -0
  17. package/dist/att.cjs +37 -0
  18. package/dist/att.cjs.map +1 -0
  19. package/dist/att.d.cts +31 -0
  20. package/dist/att.d.ts +31 -0
  21. package/dist/att.js +33 -0
  22. package/dist/att.js.map +1 -0
  23. package/dist/back-button.cjs +95 -0
  24. package/dist/back-button.cjs.map +1 -0
  25. package/dist/back-button.d.cts +45 -0
  26. package/dist/back-button.d.ts +45 -0
  27. package/dist/back-button.js +88 -0
  28. package/dist/back-button.js.map +1 -0
  29. package/dist/cli.js +723 -0
  30. package/dist/firebase.cjs +102 -0
  31. package/dist/firebase.cjs.map +1 -0
  32. package/dist/firebase.d.cts +40 -0
  33. package/dist/firebase.d.ts +40 -0
  34. package/dist/firebase.js +99 -0
  35. package/dist/firebase.js.map +1 -0
  36. package/dist/games.cjs +98 -0
  37. package/dist/games.cjs.map +1 -0
  38. package/dist/games.d.cts +73 -0
  39. package/dist/games.d.ts +73 -0
  40. package/dist/games.js +95 -0
  41. package/dist/games.js.map +1 -0
  42. package/dist/haptics.cjs +81 -0
  43. package/dist/haptics.cjs.map +1 -0
  44. package/dist/haptics.d.cts +51 -0
  45. package/dist/haptics.d.ts +51 -0
  46. package/dist/haptics.js +78 -0
  47. package/dist/haptics.js.map +1 -0
  48. package/dist/index.cjs +233 -0
  49. package/dist/index.cjs.map +1 -0
  50. package/dist/index.d.cts +99 -0
  51. package/dist/index.d.ts +99 -0
  52. package/dist/index.js +226 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/react.cjs +118 -0
  55. package/dist/react.cjs.map +1 -0
  56. package/dist/react.d.cts +51 -0
  57. package/dist/react.d.ts +51 -0
  58. package/dist/react.js +113 -0
  59. package/dist/react.js.map +1 -0
  60. package/dist/review.cjs +195 -0
  61. package/dist/review.cjs.map +1 -0
  62. package/dist/review.d.cts +76 -0
  63. package/dist/review.d.ts +76 -0
  64. package/dist/review.js +192 -0
  65. package/dist/review.js.map +1 -0
  66. package/dist/shell.cjs +97 -0
  67. package/dist/shell.cjs.map +1 -0
  68. package/dist/shell.d.cts +36 -0
  69. package/dist/shell.d.ts +36 -0
  70. package/dist/shell.js +91 -0
  71. package/dist/shell.js.map +1 -0
  72. package/dist/storage.cjs +140 -0
  73. package/dist/storage.cjs.map +1 -0
  74. package/dist/storage.d.cts +48 -0
  75. package/dist/storage.d.ts +48 -0
  76. package/dist/storage.js +136 -0
  77. package/dist/storage.js.map +1 -0
  78. package/ios/Sources/SimasdkPlugin/SimaAttPlugin.swift +41 -0
  79. package/ios/Sources/SimasdkPlugin/SimaFirebasePlugin.swift +188 -0
  80. package/ios/Sources/SimasdkPlugin/SimaGamesPlugin.swift +145 -0
  81. package/ios/Sources/SimasdkPlugin/SimaHapticsPlugin.swift +61 -0
  82. package/ios/Sources/SimasdkPlugin/SimaReviewPlugin.swift +40 -0
  83. package/ios/Sources/SimasdkPlugin/SimaStoragePlugin.swift +58 -0
  84. package/package.json +128 -4
  85. package/skills/simasdk/SKILL.md +189 -0
@@ -0,0 +1,61 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import UIKit
4
+
5
+ @objc(SimaHapticsPlugin)
6
+ public class SimaHapticsPlugin: CAPPlugin, CAPBridgedPlugin {
7
+ public let identifier = "SimaHapticsPlugin"
8
+ public let jsName = "SimaHaptics"
9
+ public let pluginMethods: [CAPPluginMethod] = [
10
+ CAPPluginMethod(name: "impact", returnType: CAPPluginReturnPromise),
11
+ CAPPluginMethod(name: "notification", returnType: CAPPluginReturnPromise),
12
+ CAPPluginMethod(name: "selection", returnType: CAPPluginReturnPromise)
13
+ ]
14
+
15
+ @objc func impact(_ call: CAPPluginCall) {
16
+ let styleName = call.getString("style") ?? "medium"
17
+ Task { @MainActor in
18
+ let style: UIImpactFeedbackGenerator.FeedbackStyle
19
+ switch styleName {
20
+ case "light":
21
+ style = .light
22
+ case "heavy":
23
+ style = .heavy
24
+ default:
25
+ style = .medium
26
+ }
27
+ let generator = UIImpactFeedbackGenerator(style: style)
28
+ generator.prepare()
29
+ generator.impactOccurred()
30
+ call.resolve()
31
+ }
32
+ }
33
+
34
+ @objc func notification(_ call: CAPPluginCall) {
35
+ let typeName = call.getString("type") ?? "success"
36
+ Task { @MainActor in
37
+ let feedbackType: UINotificationFeedbackGenerator.FeedbackType
38
+ switch typeName {
39
+ case "warning":
40
+ feedbackType = .warning
41
+ case "error":
42
+ feedbackType = .error
43
+ default:
44
+ feedbackType = .success
45
+ }
46
+ let generator = UINotificationFeedbackGenerator()
47
+ generator.prepare()
48
+ generator.notificationOccurred(feedbackType)
49
+ call.resolve()
50
+ }
51
+ }
52
+
53
+ @objc func selection(_ call: CAPPluginCall) {
54
+ Task { @MainActor in
55
+ let generator = UISelectionFeedbackGenerator()
56
+ generator.prepare()
57
+ generator.selectionChanged()
58
+ call.resolve()
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,40 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import StoreKit
4
+ import UIKit
5
+
6
+ @objc(SimaReviewPlugin)
7
+ public class SimaReviewPlugin: CAPPlugin, CAPBridgedPlugin {
8
+ public let identifier = "SimaReviewPlugin"
9
+ public let jsName = "SimaReview"
10
+ public let pluginMethods: [CAPPluginMethod] = [
11
+ CAPPluginMethod(name: "requestReview", returnType: CAPPluginReturnPromise)
12
+ ]
13
+
14
+ @objc func requestReview(_ call: CAPPluginCall) {
15
+ Task { @MainActor in
16
+ guard let scene = self.resolveWindowScene() else {
17
+ call.reject("Unable to locate an active UIWindowScene for in-app review.", "NO_WINDOW_SCENE")
18
+ return
19
+ }
20
+
21
+ if #available(iOS 16.0, *) {
22
+ AppStore.requestReview(in: scene)
23
+ } else {
24
+ SKStoreReviewController.requestReview(in: scene)
25
+ }
26
+
27
+ call.resolve()
28
+ }
29
+ }
30
+
31
+ @MainActor
32
+ private func resolveWindowScene() -> UIWindowScene? {
33
+ if let bridgeScene = self.bridge?.viewController?.view.window?.windowScene {
34
+ return bridgeScene
35
+ }
36
+
37
+ let scenes = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }
38
+ return scenes.first(where: { $0.activationState == .foregroundActive }) ?? scenes.first
39
+ }
40
+ }
@@ -0,0 +1,58 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ @objc(SimaStoragePlugin)
5
+ public class SimaStoragePlugin: CAPPlugin, CAPBridgedPlugin {
6
+ public let identifier = "SimaStoragePlugin"
7
+ public let jsName = "SimaStorage"
8
+ public let pluginMethods: [CAPPluginMethod] = [
9
+ CAPPluginMethod(name: "get", returnType: CAPPluginReturnPromise),
10
+ CAPPluginMethod(name: "set", returnType: CAPPluginReturnPromise),
11
+ CAPPluginMethod(name: "remove", returnType: CAPPluginReturnPromise),
12
+ CAPPluginMethod(name: "clearPrefix", returnType: CAPPluginReturnPromise)
13
+ ]
14
+
15
+ private let defaults = UserDefaults.standard
16
+
17
+ @objc func get(_ call: CAPPluginCall) {
18
+ guard let key = call.getString("key"), !key.isEmpty else {
19
+ call.reject("Missing required storage key.", "INVALID_KEY")
20
+ return
21
+ }
22
+ let value = defaults.string(forKey: key)
23
+ call.resolve(["value": value as Any])
24
+ }
25
+
26
+ @objc func set(_ call: CAPPluginCall) {
27
+ guard let key = call.getString("key"), !key.isEmpty else {
28
+ call.reject("Missing required storage key.", "INVALID_KEY")
29
+ return
30
+ }
31
+ guard let value = call.getString("value") else {
32
+ call.reject("Missing required string value.", "INVALID_VALUE")
33
+ return
34
+ }
35
+ defaults.set(value, forKey: key)
36
+ call.resolve()
37
+ }
38
+
39
+ @objc func remove(_ call: CAPPluginCall) {
40
+ guard let key = call.getString("key"), !key.isEmpty else {
41
+ call.reject("Missing required storage key.", "INVALID_KEY")
42
+ return
43
+ }
44
+ defaults.removeObject(forKey: key)
45
+ call.resolve()
46
+ }
47
+
48
+ @objc func clearPrefix(_ call: CAPPluginCall) {
49
+ guard let prefix = call.getString("prefix"), !prefix.isEmpty else {
50
+ call.reject("Missing required prefix.", "INVALID_KEY")
51
+ return
52
+ }
53
+ for key in defaults.dictionaryRepresentation().keys where key.hasPrefix(prefix) {
54
+ defaults.removeObject(forKey: key)
55
+ }
56
+ call.resolve()
57
+ }
58
+ }
package/package.json CHANGED
@@ -1,6 +1,130 @@
1
1
  {
2
2
  "name": "@cond/simasdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Lightweight Capacitor SDK for React apps: native Firebase Analytics bridge, In-App Review, haptics, storage, back-button stack, shell bootstrap, and AdMob policies.",
8
+ "license": "MIT",
9
+ "author": "litepacks",
10
+ "homepage": "https://github.com/litepacks/simasdk#readme",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/litepacks/simasdk.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/litepacks/simasdk/issues"
17
+ },
18
+ "type": "module",
19
+ "sideEffects": false,
20
+ "main": "./dist/index.cjs",
21
+ "module": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "bin": {
24
+ "simasdk": "./dist/cli.js"
25
+ },
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js",
30
+ "require": "./dist/index.cjs"
31
+ },
32
+ "./react": {
33
+ "types": "./dist/react.d.ts",
34
+ "import": "./dist/react.js",
35
+ "require": "./dist/react.cjs"
36
+ },
37
+ "./review": {
38
+ "types": "./dist/review.d.ts",
39
+ "import": "./dist/review.js",
40
+ "require": "./dist/review.cjs"
41
+ },
42
+ "./firebase": {
43
+ "types": "./dist/firebase.d.ts",
44
+ "import": "./dist/firebase.js",
45
+ "require": "./dist/firebase.cjs"
46
+ },
47
+ "./back-button": {
48
+ "types": "./dist/back-button.d.ts",
49
+ "import": "./dist/back-button.js",
50
+ "require": "./dist/back-button.cjs"
51
+ },
52
+ "./haptics": {
53
+ "types": "./dist/haptics.d.ts",
54
+ "import": "./dist/haptics.js",
55
+ "require": "./dist/haptics.cjs"
56
+ },
57
+ "./shell": {
58
+ "types": "./dist/shell.d.ts",
59
+ "import": "./dist/shell.js",
60
+ "require": "./dist/shell.cjs"
61
+ },
62
+ "./storage": {
63
+ "types": "./dist/storage.d.ts",
64
+ "import": "./dist/storage.js",
65
+ "require": "./dist/storage.cjs"
66
+ },
67
+ "./ads": {
68
+ "types": "./dist/ads.d.ts",
69
+ "import": "./dist/ads.js",
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"
81
+ }
82
+ },
83
+ "files": [
84
+ "dist/",
85
+ "ios/Sources/",
86
+ "android/src/",
87
+ "android/build.gradle",
88
+ "Package.swift",
89
+ "CondSimasdk.podspec",
90
+ "skills/",
91
+ "README.md"
92
+ ],
93
+ "capacitor": {
94
+ "ios": {
95
+ "src": "ios"
96
+ },
97
+ "android": {
98
+ "src": "android"
99
+ }
100
+ },
101
+ "scripts": {
102
+ "build": "tsup",
103
+ "typecheck": "tsc --noEmit",
104
+ "test": "vitest run",
105
+ "prepublishOnly": "npm run build && npm run typecheck && npm test",
106
+ "clean": "rm -rf dist *.tgz"
107
+ },
108
+ "peerDependencies": {
109
+ "@capacitor/core": "^7.0.0 || ^8.0.0",
110
+ "react": ">=18.0.0 <20.0.0"
111
+ },
112
+ "peerDependenciesMeta": {
113
+ "react": {
114
+ "optional": true
115
+ }
116
+ },
117
+ "devDependencies": {
118
+ "@capacitor/core": "^8.6.3",
119
+ "@testing-library/react": "^16.3.0",
120
+ "@types/node": "^22.10.0",
121
+ "@types/react": "^19.0.0",
122
+ "@types/react-dom": "^19.0.0",
123
+ "jsdom": "^26.1.0",
124
+ "react": "^19.0.0",
125
+ "react-dom": "^19.0.0",
126
+ "tsup": "^8.5.0",
127
+ "typescript": "^5.8.3",
128
+ "vitest": "^3.2.4"
129
+ }
130
+ }
@@ -0,0 +1,189 @@
1
+ ---
2
+ name: simasdk
3
+ description: Integrate and operate `simasdk` (litepacks/simasdk) in Capacitor 7/8 + React or vanilla TypeScript mobile apps. Use when adding native Firebase Analytics (`first_open` for Google Ads iOS/Android install campaigns or custom events), In-App Review policies, Android back-button overlay stacks, semantic haptics, native shell bootstrap (StatusBar/SplashScreen/Orientation), versioned native storage (`UserDefaults`/`SharedPreferences`), or opt-in AdMob interstitial/rewarded frequency policies.
4
+ ---
5
+
6
+ # simasdk Integration & Operations Skill
7
+
8
+ Use this runbook whenever integrating, migrating, or debugging `simasdk` in a Capacitor 7 or Capacitor 8 mobile application.
9
+
10
+ ## Core Architectural Rules (Never Violate)
11
+
12
+ 1. **Single package, zero forced third-party native bloat.**
13
+ `simasdk` never forces Firebase or AdMob into native iOS/Android builds. Only add native `FirebaseAnalytics` (Xcode SPM / Podfile / Gradle) or `@capacitor-community/admob` when the host app explicitly needs them.
14
+ 2. **Never install the Firebase Web SDK** (`firebase` npm package) for mobile analytics. `@cond/simasdk/firebase` bridges directly to native iOS/Android Firebase Analytics and safely returns `{ ok: true, status: 'ignored_web' }` on web/SSR.
15
+ 3. **Never log automatic Firebase events manually.** Never call `track('first_open')`, `track('session_start')`, or any `firebase_*` / `ga_*` / `google_*` event. Native Firebase collects `first_open` automatically once configured—even with zero React or JS event code.
16
+ 4. **Never break product flows on analytics or review failures.** `sima.track()` and `review.recordSuccess()` are non-throwing by design. Always call them *after* the user's product action succeeds.
17
+ 5. **Never rely on silent data truncation.** `track()` strictly accepts `string` (<= 100 chars) and finite `number` values only (identical on iOS and Android). Do not pass booleans, arrays, or nested objects.
18
+ 6. **React is optional.** Never import `@cond/simasdk/react` in non-React apps or utility modules that must run outside React.
19
+
20
+ ---
21
+
22
+ ## Subpath Selection Matrix
23
+
24
+ | Need | Import Path | Native Dependency Added |
25
+ | --- | --- | --- |
26
+ | Core analytics client (`createSima`) | `simasdk` | None |
27
+ | React provider & hooks (`SimaProvider`, `useSima`, `useBackHandler`, `useStoredValue`) | `@cond/simasdk/react` | None (`react` optional peer) |
28
+ | Persistent In-App Review policy (`createReviewPolicy`) | `@cond/simasdk/review` | iOS `StoreKit` (system), Android `play:review:2.0.2` |
29
+ | Native Firebase Analytics adapter (`firebaseAnalytics`) | `@cond/simasdk/firebase` | Opt-in host app `FirebaseAnalytics` / `firebase-analytics` |
30
+ | Android back-button stack & double-back exit | `@cond/simasdk/back-button` | Uses `@capacitor/app` if installed |
31
+ | Semantic haptics with persisted toggle | `@cond/simasdk/haptics` | Built-in `SimaHaptics` (iOS `UIKit`, Android `VibrationEffect`) |
32
+ | StatusBar / SplashScreen / Orientation bootstrap | `@cond/simasdk/shell` | Uses installed official `@capacitor/*` plugins only |
33
+ | Typed, versioned native key-value storage | `@cond/simasdk/storage` | Built-in `SimaStorage` (`UserDefaults` / `SharedPreferences`) |
34
+ | AdMob interstitial frequency/cooldown & rewarded policy | `@cond/simasdk/ads` | Opt-in host app `@capacitor-community/admob` |
35
+
36
+ ---
37
+
38
+ ## Integration Recipes
39
+
40
+ ### 1. Install & Sync
41
+
42
+ ```bash
43
+ npm install @cond/simasdk
44
+ npx cap sync
45
+ ```
46
+
47
+ - Supported Capacitor versions: **`^7.0.0 || ^8.0.0`**
48
+ - Supported iOS: **`14.0+`** (SwiftPM range `"7.0.0"..<"9.0.0"`, CocoaPods podspec included)
49
+ - Supported Android: **`minSdk 24`**, **Java 17** plugins (no Kotlin version conflicts between Cap 7 and Cap 8)
50
+
51
+ ### 2. Native Firebase Analytics & iOS `first_open` (Google Ads)
52
+
53
+ **Minimal install-only setup (zero React/JS event code needed):**
54
+ 1. In Xcode (`npx cap open ios`): **File -> Add Package Dependencies...** -> `https://github.com/firebase/firebase-ios-sdk.git` -> add **`FirebaseAnalytics`** to the **`App`** target.
55
+ 2. Add `GoogleService-Info.plist` to `ios/App/App/` with **Target Membership -> `App`** checked. Verify `BUNDLE_ID` matches Xcode `PRODUCT_BUNDLE_IDENTIFIER`.
56
+ 3. In `ios/App/App/AppDelegate.swift`, call `FirebaseApp.configure()` inside `application(_:didFinishLaunchingWithOptions:)`:
57
+ ```swift
58
+ import FirebaseCore
59
+ // inside didFinishLaunchingWithOptions:
60
+ FirebaseApp.configure()
61
+ ```
62
+ *(If `AppDelegate` already configures Firebase, `SimaFirebasePlugin.load()` is a safe no-op. If omitted, `SimaFirebasePlugin.load()` configures the default app when `GoogleService-Info.plist` is bundled.)*
63
+ 4. On Android: place `google-services.json` in `android/app/`, apply `com.google.gms.google-services`, and add `platform('com.google.firebase:firebase-bom:35.2.0')` + `com.google.firebase:firebase-analytics` in `android/app/build.gradle`.
64
+
65
+ **Custom events (React & outside React):**
66
+ ```ts
67
+ // src/sima.ts
68
+ import { createSima } from '@cond/simasdk';
69
+ import { firebaseAnalytics } from '@cond/simasdk/firebase';
70
+
71
+ export const sima = createSima({
72
+ analytics: firebaseAnalytics(),
73
+ onError: (err) => console.warn('[simasdk]', err.code, err.message),
74
+ });
75
+ ```
76
+
77
+ ```tsx
78
+ // Wrap app root once (StrictMode-safe pure Context provider)
79
+ <SimaProvider client={sima}>
80
+ <App />
81
+ </SimaProvider>
82
+
83
+ // Inside components
84
+ const { track } = useSima();
85
+ await exportPhoto();
86
+ await track('photo_exported', { format: 'jpeg', width: 1920 });
87
+ ```
88
+
89
+ **Start with analytics disabled prior to user consent:**
90
+ - Do **not** rely on calling `sima.setAnalyticsCollectionEnabled(false)` from JS after launch—it cannot undo startup `first_open`.
91
+ - Instead set:
92
+ - iOS `Info.plist`: `<key>FIREBASE_ANALYTICS_COLLECTION_ENABLED</key><false/>`
93
+ - Android `AndroidManifest.xml`: `<meta-data android:name="firebase_analytics_collection_enabled" android:value="false" />`
94
+ - Then call `await sima.setAnalyticsCollectionEnabled(true)` after consent is granted.
95
+
96
+ ### 3. In-App Review Policy (`@cond/simasdk/review`)
97
+
98
+ ```ts
99
+ import { createReviewPolicy } from '@cond/simasdk/review';
100
+
101
+ export const exportReview = createReviewPolicy({
102
+ key: 'successful_exports',
103
+ minimumActions: 3,
104
+ cooldownDays: 90,
105
+ });
106
+
107
+ // Call ONLY after a successful product action (never from a "Rate Us" button)
108
+ const result = await exportReview.recordSuccess();
109
+ // status: 'not_eligible' | 'cooldown' | 'requested' | 'unsupported' | 'failed'
110
+ ```
111
+
112
+ - Concurrent calls on the same `key` are serialized (at most 1 native request).
113
+ - Failed native calls persist `actionCount` but **do not** start cooldown.
114
+ - `'requested'` means the OS API was invoked; never assume the OS showed a prompt or that the user rated the app.
115
+
116
+ ### 4. Android Back Button Stack (`@cond/simasdk/back-button` + `@cond/simasdk/react`)
117
+
118
+ ```ts
119
+ import {
120
+ attachCapacitorBackButton,
121
+ createDoubleBackExit,
122
+ registerBackHandler,
123
+ } from '@cond/simasdk/back-button';
124
+
125
+ await attachCapacitorBackButton();
126
+ registerBackHandler(
127
+ createDoubleBackExit({ windowMs: 2000, onFirstPress: () => showToast('Press back again to exit') }),
128
+ { priority: 0 },
129
+ );
130
+ ```
131
+
132
+ In React modals/sheets:
133
+ ```tsx
134
+ import { useBackHandler } from '@cond/simasdk/react';
135
+
136
+ useBackHandler(() => {
137
+ closeSheet();
138
+ return true;
139
+ }, { enabled: isOpen, priority: 100 });
140
+ ```
141
+
142
+ ### 5. Haptics, Shell, Storage, and AdMob Policy
143
+
144
+ ```ts
145
+ // Haptics (persisted on/off toggle, zero-throw web no-op)
146
+ import { createHaptics } from '@cond/simasdk/haptics';
147
+ export const haptics = createHaptics();
148
+ await haptics.light();
149
+ await haptics.success();
150
+
151
+ // Native Shell Bootstrap (only touches installed @capacitor/* plugins)
152
+ import { initShell } from '@cond/simasdk/shell';
153
+ await initShell({ statusBarStyle: 'dark', orientation: 'portrait', hideSplash: true });
154
+
155
+ // Versioned Native Storage (UserDefaults / SharedPreferences / localStorage)
156
+ import { createStorage } from '@cond/simasdk/storage';
157
+ export const settingsStore = createStorage({ namespace: 'settings', version: 1 });
158
+ await settingsStore.set('sound', true);
159
+
160
+ // Opt-in AdMob Interstitial / Rewarded Policy (lazy @capacitor-community/admob bridge)
161
+ import { createAdPolicy } from '@cond/simasdk/ads';
162
+ export const levelAds = createAdPolicy({
163
+ key: 'level_complete',
164
+ interstitialAdId: { ios: 'ca-app-pub-ios', android: 'ca-app-pub-android' },
165
+ minActionsBeforeFirst: 2,
166
+ actionsBetweenAds: 3,
167
+ cooldownSeconds: 90,
168
+ disabled: () => isProUser(),
169
+ });
170
+ await levelAds.recordActionAndMaybeShow();
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Verification & Debugging Checklist
176
+
177
+ 1. **Automated project audit:** Run `npx simasdk doctor` (or `npx simasdk doctor --json`) to check Capacitor version compatibility, iOS plugin sync, `GoogleService-Info.plist` Bundle ID & Target Membership, `FirebaseApp.configure()`, and Android Gradle/manifest config.
178
+ 2. **Scaffold starter file:** Run `npx simasdk init --firebase --review --haptics --storage --back-button --shell` (or `--all`) to create `src/sima.ts`.
179
+ 3. **Plugin discovery:** After `npx cap sync ios`, confirm `ios/App/App/capacitor.config.json` includes `SimaFirebasePlugin`, `SimaReviewPlugin`, `SimaHapticsPlugin`, and `SimaStoragePlugin`.
180
+ 2. **Firebase DebugView (iOS):** Add `-FIRDebugEnabled` to Xcode Scheme -> Run -> Arguments, reinstall the app on a device/simulator, and confirm `first_open` appears in **Firebase Console -> Analytics -> DebugView**.
181
+ 3. **Google Ads iOS `first_open`:** Ensure **App Store ID** is set in Firebase Project Settings -> iOS app, the correct GA4 property is linked in **Google Ads -> Data Manager -> Google Analytics (GA4) & Firebase**, and the **iOS** stream's `first_open` (not Android's) is imported under **Goals -> Conversions** as **Primary**.
182
+ 4. **Never commit secrets:** Keep `GoogleService-Info.plist` and `google-services.json` out of public git repositories.
183
+
184
+ ## Common Mistakes to Avoid
185
+
186
+ - Calling `review.recordSuccess()` on a "Rate Us" button in Settings (violates Apple HIG; use an App Store `?action=write-review` URL instead).
187
+ - Passing boolean values in `sima.track(event, { is_pro: true })` — use strings or numbers (`{ plan: 'pro' }` or `{ is_pro: 1 }`).
188
+ - Checking `track()` only in a browser preview and assuming native Firebase works — browser always returns `ignored_web`; verify on a native iOS/Android build where missing config returns `NATIVE_NOT_CONFIGURED`.
189
+ - Assuming DebugView visibility means Google Ads is ready — DebugView traffic is excluded from production GA4/Google Ads reports; run a non-debug install and allow 24–72 hours for iOS conversion sync.