1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Free, bundled Mobiler plugin: remote push (server-sent notifications via APNs/FCM). The companion
# to the LOCAL `notifications` plugin. Two surfaces, both riding existing primitives:
# cx.plugin("push", "register", "", |r| Msg::PushToken(r)) // → {"token":"…","platform":"apns"|"fcm"}
# cx.subscribe("push", "push", "events", "", |r| Msg::PushEvent(r)) // each received/tapped payload,
# // or {"type":"token_refresh","token":"…"}
# Register returns the device token; POST it (with your tenant) to your backend via cx.http. The
# events stream delivers foreground-received + tapped notifications (and token rotations).
#
# iOS = native APNs via system frameworks (no third-party SDK). The shell's AppDelegate forwards the
# APNs token + notification callbacks to `PushBridge`; this plugin adapts them to the cx ABI.
# Android = Firebase Cloud Messaging (the only way to get a device token on stock Android).
#
# Install: mobiler plugin add push
# TWO manual steps `plugin add` can't do (see notes below): drop `google-services.json` into
# Android/app/, and enable Push Notifications on your App ID + match `aps-environment` to your signing.
= "push"
= "Remote push (APNs/FCM) — server-sent notifications (free; EXPERIMENTAL — not yet device-tested)"
= [
"EXPERIMENTAL: the iOS receive path is simulator-verified, but the real APNs/FCM token round-trip hasn't been validated on a physical device yet. See the plugin README.",
"Android: download google-services.json from your Firebase console into Android/app/ — it carries your project's keys and can't be bundled. The Android build FAILS without it.",
"iOS: the 'aps-environment' entitlement was added as 'development' (APNs sandbox / TestFlight). Switch it to 'production' for App Store builds — a mismatch is the #1 reason push silently never arrives.",
]
[]
= ["android/PushPlugin.kt", "android/PushMessagingService.kt"]
= '"push" to PushPlugin(application)'
# POST_NOTIFICATIONS is the Android 13+ runtime permission for posting notifications.
= ["android.permission.POST_NOTIFICATIONS"]
= ["com.google.firebase:firebase-messaging:24.1.0"]
# FCM needs the google-services Gradle PLUGIN applied (it processes google-services.json) — not just
# a dependency. `gradle_plugins` applies it in the app block + declares it (apply false) at project level.
= ["com.google.gms.google-services:4.4.2"]
# The FCM service must be statically declared so it runs even when the app process is dead.
= ['<service android:name=".PushMessagingService" android:exported="false"><intent-filter><action android:name="com.google.firebase.MESSAGING_EVENT"/></intent-filter></service>']
[]
= ["ios/PushPlugin.swift"]
= 'case "push": return await PushPlugin.handle(op: op, input: input)'
= 'case "push": await PushPlugin.subscribe(op: op, input: input, emit: emit)'
# Remote push requires the aps-environment entitlement. "development" = APNs sandbox (debug +
# TestFlight); switch to "production" for App Store. Also enable Push Notifications on the App ID.
[]
= "development"