푸시 알림
푸시 알림 연동 가이드
Hibira Push로 iOS, Android, 브라우저에 알림을 보내세요. API는 Beams와 호환되어 공식 Beams 서버 SDK는 엔드포인트만 지정하면 동작하고, 저희 클라이언트 SDK는 호스트를 설정할 수 있게 만든 Beams SDK의 포크입니다.
로그인하면 스니펫이 내 엔드포인트로 바뀌고, 앱 페이지에서는 인스턴스 ID도 채워집니다. 로그인
동작 방식
- 포털의 앱 페이지에서 푸시 알림을 켜면 인스턴스 ID, 시크릿 키, 엔드포인트가 발급됩니다.
- 각 기기나 브라우저는 클라이언트 SDK로 등록하고 news, order-1024 같은 주제인 관심사(interest)를 구독합니다. 서버는 관심사로 발송하고, 기기가 로그인한 사용자와 연결되면 사용자 ID로도 발송할 수 있습니다.
- 인스턴스 ID와 엔드포인트는 앱에 넣습니다. 시크릿 키는 모든 기기에 발송할 수 있으므로 서버의 HIBIRA_PUSH_SECRET_KEY 환경 변수에만 두고, 앱이나 저장소에는 절대 넣지 마세요.
- 푸시는 모든 플랜에 포함됩니다. 플랜에 따라 등록할 수 있는 기기와 브라우저 수, 발송 속도가 정해집니다.
1. 자격 증명 업로드
- Apple (APNs)
- Apple Developer의 Certificates, Identifiers & Profiles › Keys에서 Apple Push Notifications service(APNs)를 켠 키를 만들고 .p8 파일을 내려받으세요. 앱 페이지의 푸시 알림 › Apple(APNs)에서 키 ID, 팀 ID, 앱의 번들 ID를 입력하고 환경을 고른 뒤 .p8 파일을 업로드하세요. Xcode에서 실행하는 빌드는 개발(샌드박스), TestFlight와 App Store 빌드는 프로덕션을 선택하세요.
- Android (FCM)
- Firebase 콘솔에서 프로젝트 설정 › 서비스 계정을 열고 새 비공개 키 생성을 클릭하세요. JSON 파일을 푸시 알림 › Android(FCM)에 업로드하고, 같은 프로젝트의 google-services.json을 Android 앱에 추가하세요.
- Web Push
- 업로드할 것이 없습니다. VAPID 키는 푸시를 켤 때 만들어집니다. 사이트는 HTTPS로 제공해야 합니다(개발 중에는 localhost도 됩니다).
키와 서비스 계정은 암호화해 저장하며 다시 표시되지 않습니다.
2. 기기와 브라우저 등록
클라이언트 SDK
Chrome, Edge, Firefox, Opera, Safari 16.4 이상에서 표준 Web Push와 서비스 워커로 동작합니다. @hibira-io/push-web ↗
설치
npm install @hibira-io/push-web서비스 워커 추가
// public/service-worker.js, served at https://your-site/service-worker.js importScripts('https://cdn.jsdelivr.net/npm/@hibira-io/push-web@1/dist/service-worker.js'); self.HibiraPush.endpoint = 'https://ws.hibira.io';브라우저 등록
import { Client } from '@hibira-io/push-web'; const push = new Client({ instanceId: 'YOUR_INSTANCE_ID', endpoint: 'https://ws.hibira.io', }); // Browsers only show the permission prompt after a click or tap. document.querySelector('#enable-notifications').addEventListener('click', async () => { await push.start(); await push.addDeviceInterest('hello'); });로그인한 사용자 연결
import { TokenProvider } from '@hibira-io/push-web'; // After sign-in. Your backend answers GET /push/user-token?user_id=... (see the server guide). await push.setUserId(currentUser.id, new TokenProvider({ url: '/push/user-token' })); // On sign-out, so the next person on this browser doesn't get their notifications. await push.stop();
Web용 에이전트 프롬프트
Claude Code, Cursor, GitHub Copilot 등 AI 코딩 에이전트에 붙여 넣으세요. 인스턴스 ID와 엔드포인트가 들어 있고, 시크릿 키는 환경 변수로 남습니다.
Add Hibira push notifications to this Web project. Hibira Push sends to iOS (APNs), Android (FCM) and browsers (Web Push) through a Beams-compatible API, so it works with the Hibira client SDK (here: @hibira-io/push-web, https://github.com/hibira-io/hibira-push-web).
Connection details:
- Instance ID: YOUR_INSTANCE_ID
- Endpoint: https://ws.hibira.io
- No secret key: it belongs on the server, never in this app
What to do:
1. Look at the project first (framework version, package manager, config and env conventions, where similar integrations live) and follow what it already does.
2. Install @hibira-io/push-web (it replaces @pusher/push-notifications-web; the API is the same apart from the import and the endpoint option).
3. Serve service-worker.js from the site root (for example public/service-worker.js in Vite, Next.js or Create React App) with the importScripts line and the endpoint from the reference.
4. Create one shared push client module and call start() from a user action such as an "Enable notifications" button, never on page load: browsers block permission prompts that are not triggered by a click.
5. If the app has signed-in users, call setUserId with a TokenProvider pointing at the backend token endpoint after sign-in, and stop() on sign-out.
6. Web Push needs HTTPS (localhost is fine for development); on iPhone and iPad it works only once the site is added to the Home Screen.
7. Read the instance ID and endpoint from the project's config or environment, and add placeholder entries to .env.example (or its equivalent).
8. Always set the endpoint above. The Pusher Beams SDKs and their defaults point at pusher.com.
9. If YOUR_INSTANCE_ID above is still a placeholder, keep it as a config placeholder and tell me where to fill it in rather than inventing a value.
10. Subscribe test devices to the "hello" interest so the portal's Send a test reaches them.
11. When you are done, list the files you changed and tell me how to check it works: on the Hibira portal app page, Push notifications › Send a test to the hello interest.
Reference setup from the Hibira push notifications guide (adapt it to the project's structure):
Install:
```shell
npm install @hibira-io/push-web
```
Add the service worker:
```js
// public/service-worker.js, served at https://your-site/service-worker.js
importScripts('https://cdn.jsdelivr.net/npm/@hibira-io/push-web@1/dist/service-worker.js');
self.HibiraPush.endpoint = 'https://ws.hibira.io';
```
Register the browser:
```js
import { Client } from '@hibira-io/push-web';
const push = new Client({
instanceId: 'YOUR_INSTANCE_ID',
endpoint: 'https://ws.hibira.io',
});
// Browsers only show the permission prompt after a click or tap.
document.querySelector('#enable-notifications').addEventListener('click', async () => {
await push.start();
await push.addDeviceInterest('hello');
});
```
Link the signed-in user:
```js
import { TokenProvider } from '@hibira-io/push-web';
// After sign-in. Your backend answers GET /push/user-token?user_id=... (see the server guide).
await push.setUserId(currentUser.id, new TokenProvider({ url: '/push/user-token' }));
// On sign-out, so the next person on this browser doesn't get their notifications.
await push.stop();
```
Kotlin 또는 Java로 만든 Android 7.0 이상 앱. Firebase Cloud Messaging으로 전달됩니다. hibira-push-android ↗
Gradle 의존성 추가
// settings.gradle.kts dependencyResolutionManagement { repositories { google() mavenCentral() maven("https://jitpack.io") } } // app/build.gradle.kts (google-services.json from Firebase goes in app/) plugins { id("com.android.application") id("com.google.gms.google-services") } dependencies { implementation("com.google.firebase:firebase-messaging:23.4.0") implementation("com.github.hibira-io:hibira-push-android:1.0.0") }SDK 시작
import android.app.Application import io.hibira.push.PushNotifications class App : Application() { override fun onCreate() { super.onCreate() PushNotifications.setEndpoint(this, "https://ws.hibira.io") PushNotifications.start(this, "YOUR_INSTANCE_ID") PushNotifications.addDeviceInterest("hello") } }알림 권한 요청
// AndroidManifest.xml: <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> // Android 13+ shows nothing until the user allows notifications. if (Build.VERSION.SDK_INT >= 33) { requestPermissions(arrayOf(Manifest.permission.POST_NOTIFICATIONS), 1) }로그인한 사용자 연결
import io.hibira.push.PushCallback import io.hibira.push.PushCallbackError import io.hibira.push.auth.AuthData import io.hibira.push.auth.AuthDataGetter import io.hibira.push.auth.PushTokenProvider val tokenProvider = PushTokenProvider( "https://api.your-app.example/push/user-token", object : AuthDataGetter { override fun getAuthData() = AuthData( headers = hashMapOf("Authorization" to "Bearer $sessionToken"), ) }, ) PushNotifications.setUserId(userId, tokenProvider, object : PushCallback<Void, PushCallbackError> { override fun onSuccess(vararg values: Void) {} override fun onFailure(error: PushCallbackError) { Log.w("push", error.message) } }) // On sign-out: PushNotifications.stop()
Android용 에이전트 프롬프트
Claude Code, Cursor, GitHub Copilot 등 AI 코딩 에이전트에 붙여 넣으세요. 인스턴스 ID와 엔드포인트가 들어 있고, 시크릿 키는 환경 변수로 남습니다.
Add Hibira push notifications to this Android project. Hibira Push sends to iOS (APNs), Android (FCM) and browsers (Web Push) through a Beams-compatible API, so it works with the Hibira client SDK (here: hibira-push-android, https://github.com/hibira-io/hibira-push-android).
Connection details:
- Instance ID: YOUR_INSTANCE_ID
- Endpoint: https://ws.hibira.io
- No secret key: it belongs on the server, never in this app
What to do:
1. Look at the project first (framework version, package manager, config and env conventions, where similar integrations live) and follow what it already does.
2. Add the JitPack repository and com.github.hibira-io:hibira-push-android (package io.hibira.push; it replaces com.pusher:push-notifications-android). The app needs the Google services Gradle plugin and its google-services.json from the same Firebase project whose service account is uploaded in the portal.
3. Call PushNotifications.setEndpoint and then PushNotifications.start in the Application class (create one and register it in AndroidManifest.xml if the app has none); keep the instance ID and endpoint in BuildConfig fields or resources.
4. On Android 13 and later, declare POST_NOTIFICATIONS in the manifest and request it at a sensible moment (for example after the user turns notifications on), using the project's existing permission approach.
5. If the app has signed-in users, call setUserId with a PushTokenProvider pointing at the backend token endpoint (sending the session credentials) after sign-in, and PushNotifications.stop() on sign-out.
6. Read the instance ID and endpoint from the project's config or environment, and add placeholder entries to .env.example (or its equivalent).
7. Always set the endpoint above. The Pusher Beams SDKs and their defaults point at pusher.com.
8. If YOUR_INSTANCE_ID above is still a placeholder, keep it as a config placeholder and tell me where to fill it in rather than inventing a value.
9. Subscribe test devices to the "hello" interest so the portal's Send a test reaches them.
10. When you are done, list the files you changed and tell me how to check it works: on the Hibira portal app page, Push notifications › Send a test to the hello interest.
Reference setup from the Hibira push notifications guide (adapt it to the project's structure):
Add the Gradle dependencies:
```kotlin
// settings.gradle.kts
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}
// app/build.gradle.kts (google-services.json from Firebase goes in app/)
plugins {
id("com.android.application")
id("com.google.gms.google-services")
}
dependencies {
implementation("com.google.firebase:firebase-messaging:23.4.0")
implementation("com.github.hibira-io:hibira-push-android:1.0.0")
}
```
Start the SDK:
```kotlin
import android.app.Application
import io.hibira.push.PushNotifications
class App : Application() {
override fun onCreate() {
super.onCreate()
PushNotifications.setEndpoint(this, "https://ws.hibira.io")
PushNotifications.start(this, "YOUR_INSTANCE_ID")
PushNotifications.addDeviceInterest("hello")
}
}
```
Ask for notification permission:
```kotlin
// AndroidManifest.xml: <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
// Android 13+ shows nothing until the user allows notifications.
if (Build.VERSION.SDK_INT >= 33) {
requestPermissions(arrayOf(Manifest.permission.POST_NOTIFICATIONS), 1)
}
```
Link the signed-in user:
```kotlin
import io.hibira.push.PushCallback
import io.hibira.push.PushCallbackError
import io.hibira.push.auth.AuthData
import io.hibira.push.auth.AuthDataGetter
import io.hibira.push.auth.PushTokenProvider
val tokenProvider = PushTokenProvider(
"https://api.your-app.example/push/user-token",
object : AuthDataGetter {
override fun getAuthData() = AuthData(
headers = hashMapOf("Authorization" to "Bearer $sessionToken"),
)
},
)
PushNotifications.setUserId(userId, tokenProvider, object : PushCallback<Void, PushCallbackError> {
override fun onSuccess(vararg values: Void) {}
override fun onFailure(error: PushCallbackError) { Log.w("push", error.message) }
})
// On sign-out:
PushNotifications.stop()
```
iOS 15 이상, macOS 12 이상의 Swift 앱. APNs로 전달됩니다. HibiraPush ↗
설치
// Xcode: File › Add Package Dependencies › https://github.com/hibira-io/hibira-push-ios // or in Package.swift: .package(url: "https://github.com/hibira-io/hibira-push-ios", from: "1.0.0") // Then turn on Signing & Capabilities › Push Notifications for the app target.알림 등록
import HibiraPush import UIKit final class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { PushNotifications.shared.setEndpoint("https://ws.hibira.io") PushNotifications.shared.start(instanceId: "YOUR_INSTANCE_ID") PushNotifications.shared.registerForRemoteNotifications() try? PushNotifications.shared.addDeviceInterest(interest: "hello") return true } func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { PushNotifications.shared.registerDeviceToken(deviceToken) } func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { PushNotifications.shared.handleNotification(userInfo: userInfo) completionHandler(.noData) } }로그인한 사용자 연결
let tokenProvider = PushTokenProvider(authURL: "https://api.your-app.example/push/user-token") { AuthData(headers: ["Authorization": "Bearer \(sessionToken)"], queryParams: [:]) } PushNotifications.shared.setUserId(userId, tokenProvider: tokenProvider) { error in if let error = error { print("push:", error) } } // On sign-out: PushNotifications.shared.stop { }
iOS / macOS용 에이전트 프롬프트
Claude Code, Cursor, GitHub Copilot 등 AI 코딩 에이전트에 붙여 넣으세요. 인스턴스 ID와 엔드포인트가 들어 있고, 시크릿 키는 환경 변수로 남습니다.
Add Hibira push notifications to this iOS / macOS project. Hibira Push sends to iOS (APNs), Android (FCM) and browsers (Web Push) through a Beams-compatible API, so it works with the Hibira client SDK (here: HibiraPush, https://github.com/hibira-io/hibira-push-ios).
Connection details:
- Instance ID: YOUR_INSTANCE_ID
- Endpoint: https://ws.hibira.io
- No secret key: it belongs on the server, never in this app
What to do:
1. Look at the project first (framework version, package manager, config and env conventions, where similar integrations live) and follow what it already does.
2. Add the Swift package https://github.com/hibira-io/hibira-push-ios (product HibiraPush; it replaces pusher/push-notifications-swift and PushNotifications keeps its name) and turn on the Push Notifications capability for the app target.
3. In a SwiftUI app, add a UIApplicationDelegateAdaptor for the AppDelegate in the reference; keep the instance ID and endpoint in an xcconfig or Info.plist entry (the HibiraPushEndpoint Info.plist key also sets the endpoint).
4. Call setEndpoint before start, forward the device token from didRegisterForRemoteNotificationsWithDeviceToken, and pass received notifications to handleNotification.
5. If the app has signed-in users, call setUserId with a PushTokenProvider pointing at the backend token endpoint (sending the session credentials) after sign-in, and stop on sign-out.
6. Remind me that the APNs environment chosen in the portal must match the build: Development (sandbox) for Xcode builds, Production for TestFlight and the App Store.
7. Read the instance ID and endpoint from the project's config or environment, and add placeholder entries to .env.example (or its equivalent).
8. Always set the endpoint above. The Pusher Beams SDKs and their defaults point at pusher.com.
9. If YOUR_INSTANCE_ID above is still a placeholder, keep it as a config placeholder and tell me where to fill it in rather than inventing a value.
10. Subscribe test devices to the "hello" interest so the portal's Send a test reaches them.
11. When you are done, list the files you changed and tell me how to check it works: on the Hibira portal app page, Push notifications › Send a test to the hello interest.
Reference setup from the Hibira push notifications guide (adapt it to the project's structure):
Install:
```swift
// Xcode: File › Add Package Dependencies › https://github.com/hibira-io/hibira-push-ios
// or in Package.swift:
.package(url: "https://github.com/hibira-io/hibira-push-ios", from: "1.0.0")
// Then turn on Signing & Capabilities › Push Notifications for the app target.
```
Register for notifications:
```swift
import HibiraPush
import UIKit
final class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
PushNotifications.shared.setEndpoint("https://ws.hibira.io")
PushNotifications.shared.start(instanceId: "YOUR_INSTANCE_ID")
PushNotifications.shared.registerForRemoteNotifications()
try? PushNotifications.shared.addDeviceInterest(interest: "hello")
return true
}
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
PushNotifications.shared.registerDeviceToken(deviceToken)
}
func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
PushNotifications.shared.handleNotification(userInfo: userInfo)
completionHandler(.noData)
}
}
```
Link the signed-in user:
```swift
let tokenProvider = PushTokenProvider(authURL: "https://api.your-app.example/push/user-token") {
AuthData(headers: ["Authorization": "Bearer \(sessionToken)"], queryParams: [:])
}
PushNotifications.shared.setUserId(userId, tokenProvider: tokenProvider) { error in
if let error = error { print("push:", error) }
}
// On sign-out:
PushNotifications.shared.stop { }
```
3. 서버에서 발송
서버 SDK
공식 Beams 서버 SDK를 엔드포인트로 지정해 Node.js에서 발송합니다. @pusher/push-notifications-server ↗
설치
npm install @pusher/push-notifications-server관심사에 발송
const PushNotifications = require('@pusher/push-notifications-server'); const beams = new PushNotifications({ instanceId: 'YOUR_INSTANCE_ID', secretKey: process.env.HIBIRA_PUSH_SECRET_KEY, endpoint: 'ws.hibira.io', }); beams.protocol = 'https'; // the SDK switches to http when an endpoint is set await beams.publishToInterests(['hello'], { apns: { aps: { alert: { title: 'Hello', body: 'Hello, world!' } } }, fcm: { notification: { title: 'Hello', body: 'Hello, world!' } }, web: { notification: { title: 'Hello', body: 'Hello, world!', deep_link: 'https://your-site.example/' } }, });사용자 토큰 엔드포인트 추가
// Express: the client SDKs call GET /push/user-token?user_id=... app.get('/push/user-token', requireLogin, (req, res) => { if (req.query.user_id !== String(req.user.id)) return res.sendStatus(401); res.json(beams.generateToken(String(req.user.id))); // { token: '...' } });로그인한 사용자에게 발송
await beams.publishToUsers(['user-1'], { apns: { aps: { alert: { title: 'Order shipped', body: 'Order #1024 is on its way.' } } }, fcm: { notification: { title: 'Order shipped', body: 'Order #1024 is on its way.' } }, web: { notification: { title: 'Order shipped', body: 'Order #1024 is on its way.' } }, });
Node.js용 에이전트 프롬프트
Claude Code, Cursor, GitHub Copilot 등 AI 코딩 에이전트에 붙여 넣으세요. 인스턴스 ID와 엔드포인트가 들어 있고, 시크릿 키는 환경 변수로 남습니다.
Add Hibira push notifications to this Node.js project. Hibira Push sends to iOS (APNs), Android (FCM) and browsers (Web Push) through a Beams-compatible API, so it works with the official Beams server SDKs pointed at the Hibira endpoint (here: @pusher/push-notifications-server, https://github.com/pusher/push-notifications-node).
Connection details:
- Instance ID: YOUR_INSTANCE_ID
- Endpoint: https://ws.hibira.io
- Secret key: read it from the HIBIRA_PUSH_SECRET_KEY environment variable (server-side only)
What to do:
1. Look at the project first (framework version, package manager, config and env conventions, where similar integrations live) and follow what it already does.
2. Create one shared module that builds the PushNotifications client from environment variables, with the endpoint option and beams.protocol set as in the reference (without them the SDK talks to pusher.com, or to the endpoint over plain http).
3. If the app has signed-in users, add the token route behind the project's existing authentication middleware; it must refuse a user_id that is not the signed-in user's.
4. Publish from the places that should notify (jobs, controllers, event handlers) through the shared module, and log the publish ID it returns.
5. Read the instance ID and endpoint from the project's config or environment, and add placeholder entries to .env.example (or its equivalent). Never commit the secret key or send it to a browser or mobile app.
6. Always set the endpoint above. The Pusher Beams SDKs and their defaults point at pusher.com.
7. If YOUR_INSTANCE_ID above is still a placeholder, keep it as a config placeholder and tell me where to fill it in rather than inventing a value.
8. Subscribe test devices to the "hello" interest so the portal's Send a test reaches them.
9. When you are done, list the files you changed and tell me how to check it works: on the Hibira portal app page, Push notifications › Send a test to the hello interest.
Reference setup from the Hibira push notifications guide (adapt it to the project's structure):
Install:
```shell
npm install @pusher/push-notifications-server
```
Publish to an interest:
```js
const PushNotifications = require('@pusher/push-notifications-server');
const beams = new PushNotifications({
instanceId: 'YOUR_INSTANCE_ID',
secretKey: process.env.HIBIRA_PUSH_SECRET_KEY,
endpoint: 'ws.hibira.io',
});
beams.protocol = 'https'; // the SDK switches to http when an endpoint is set
await beams.publishToInterests(['hello'], {
apns: { aps: { alert: { title: 'Hello', body: 'Hello, world!' } } },
fcm: { notification: { title: 'Hello', body: 'Hello, world!' } },
web: { notification: { title: 'Hello', body: 'Hello, world!', deep_link: 'https://your-site.example/' } },
});
```
Add the user token endpoint:
```js
// Express: the client SDKs call GET /push/user-token?user_id=...
app.get('/push/user-token', requireLogin, (req, res) => {
if (req.query.user_id !== String(req.user.id)) return res.sendStatus(401);
res.json(beams.generateToken(String(req.user.id))); // { token: '...' }
});
```
Publish to a signed-in user:
```js
await beams.publishToUsers(['user-1'], {
apns: { aps: { alert: { title: 'Order shipped', body: 'Order #1024 is on its way.' } } },
fcm: { notification: { title: 'Order shipped', body: 'Order #1024 is on its way.' } },
web: { notification: { title: 'Order shipped', body: 'Order #1024 is on its way.' } },
});
```
공식 Beams 서버 SDK를 엔드포인트로 지정해 모든 PHP 앱에서 발송합니다. pusher/pusher-push-notifications ↗
설치
composer require pusher/pusher-push-notifications관심사에 발송
use Pusher\PushNotifications\PushNotifications; $beams = new PushNotifications([ 'instanceId' => 'YOUR_INSTANCE_ID', 'secretKey' => getenv('HIBIRA_PUSH_SECRET_KEY'), 'endpoint' => 'https://ws.hibira.io', ]); $beams->publishToInterests(['hello'], [ 'apns' => ['aps' => ['alert' => ['title' => 'Hello', 'body' => 'Hello, world!']]], 'fcm' => ['notification' => ['title' => 'Hello', 'body' => 'Hello, world!']], 'web' => ['notification' => ['title' => 'Hello', 'body' => 'Hello, world!']], ]);사용자 토큰 엔드포인트 추가
// GET /push/user-token?user_id=..., for a signed-in user only $userId = (string) $currentUser->id; if (($_GET['user_id'] ?? '') !== $userId) { http_response_code(401); exit; } header('Content-Type: application/json'); echo json_encode($beams->generateToken($userId)); // {"token": "..."}로그인한 사용자에게 발송
$beams->publishToUsers(['user-1'], [ 'apns' => ['aps' => ['alert' => ['title' => 'Order shipped', 'body' => 'Order #1024 is on its way.']]], 'fcm' => ['notification' => ['title' => 'Order shipped', 'body' => 'Order #1024 is on its way.']], 'web' => ['notification' => ['title' => 'Order shipped', 'body' => 'Order #1024 is on its way.']], ]);
PHP용 에이전트 프롬프트
Claude Code, Cursor, GitHub Copilot 등 AI 코딩 에이전트에 붙여 넣으세요. 인스턴스 ID와 엔드포인트가 들어 있고, 시크릿 키는 환경 변수로 남습니다.
Add Hibira push notifications to this PHP project. Hibira Push sends to iOS (APNs), Android (FCM) and browsers (Web Push) through a Beams-compatible API, so it works with the official Beams server SDKs pointed at the Hibira endpoint (here: pusher/pusher-push-notifications, https://github.com/pusher/push-notifications-php).
Connection details:
- Instance ID: YOUR_INSTANCE_ID
- Endpoint: https://ws.hibira.io
- Secret key: read it from the HIBIRA_PUSH_SECRET_KEY environment variable (server-side only)
What to do:
1. Look at the project first (framework version, package manager, config and env conventions, where similar integrations live) and follow what it already does.
2. Create one small factory or service that builds PushNotifications from environment variables, always with the endpoint option (without it the SDK talks to pusher.com), and use it wherever the app publishes.
3. If the app has signed-in users, add the token endpoint behind the project's existing session check; it must refuse a user_id that is not the signed-in user's.
4. Read the instance ID and endpoint from the project's config or environment, and add placeholder entries to .env.example (or its equivalent). Never commit the secret key or send it to a browser or mobile app.
5. Always set the endpoint above. The Pusher Beams SDKs and their defaults point at pusher.com.
6. If YOUR_INSTANCE_ID above is still a placeholder, keep it as a config placeholder and tell me where to fill it in rather than inventing a value.
7. Subscribe test devices to the "hello" interest so the portal's Send a test reaches them.
8. When you are done, list the files you changed and tell me how to check it works: on the Hibira portal app page, Push notifications › Send a test to the hello interest.
Reference setup from the Hibira push notifications guide (adapt it to the project's structure):
Install:
```shell
composer require pusher/pusher-push-notifications
```
Publish to an interest:
```php
use Pusher\PushNotifications\PushNotifications;
$beams = new PushNotifications([
'instanceId' => 'YOUR_INSTANCE_ID',
'secretKey' => getenv('HIBIRA_PUSH_SECRET_KEY'),
'endpoint' => 'https://ws.hibira.io',
]);
$beams->publishToInterests(['hello'], [
'apns' => ['aps' => ['alert' => ['title' => 'Hello', 'body' => 'Hello, world!']]],
'fcm' => ['notification' => ['title' => 'Hello', 'body' => 'Hello, world!']],
'web' => ['notification' => ['title' => 'Hello', 'body' => 'Hello, world!']],
]);
```
Add the user token endpoint:
```php
// GET /push/user-token?user_id=..., for a signed-in user only
$userId = (string) $currentUser->id;
if (($_GET['user_id'] ?? '') !== $userId) {
http_response_code(401);
exit;
}
header('Content-Type: application/json');
echo json_encode($beams->generateToken($userId)); // {"token": "..."}
```
Publish to a signed-in user:
```php
$beams->publishToUsers(['user-1'], [
'apns' => ['aps' => ['alert' => ['title' => 'Order shipped', 'body' => 'Order #1024 is on its way.']]],
'fcm' => ['notification' => ['title' => 'Order shipped', 'body' => 'Order #1024 is on its way.']],
'web' => ['notification' => ['title' => 'Order shipped', 'body' => 'Order #1024 is on its way.']],
]);
```
Laravel 앱: 엔드포인트를 넣은 컨테이너 바인딩, 토큰 라우트, 잡에서의 발송. pusher/pusher-push-notifications ↗
설치
composer require pusher/pusher-push-notifications푸시 자격 증명 설정
HIBIRA_PUSH_INSTANCE_ID=YOUR_INSTANCE_ID HIBIRA_PUSH_SECRET_KEY= HIBIRA_PUSH_ENDPOINT=https://ws.hibira.io클라이언트 바인딩
// config/services.php 'hibira_push' => [ 'instance_id' => env('HIBIRA_PUSH_INSTANCE_ID'), 'secret_key' => env('HIBIRA_PUSH_SECRET_KEY'), 'endpoint' => env('HIBIRA_PUSH_ENDPOINT'), ], // app/Providers/AppServiceProvider.php, in register() $this->app->singleton(\Pusher\PushNotifications\PushNotifications::class, fn () => new \Pusher\PushNotifications\PushNotifications([ 'instanceId' => config('services.hibira_push.instance_id'), 'secretKey' => config('services.hibira_push.secret_key'), 'endpoint' => config('services.hibira_push.endpoint'), ]));사용자 토큰 엔드포인트 추가
// routes/web.php (or routes/api.php with your API guard) use Illuminate\Http\Request; use Pusher\PushNotifications\PushNotifications; Route::middleware('auth')->get('/push/user-token', function (Request $request, PushNotifications $beams) { $userId = (string) $request->user()->id; abort_unless($request->query('user_id') === $userId, 401); return $beams->generateToken($userId); // {"token": "..."} });로그인한 사용자에게 발송
app(\Pusher\PushNotifications\PushNotifications::class)->publishToUsers([(string) $order->user_id], [ 'apns' => ['aps' => ['alert' => ['title' => 'Order shipped', 'body' => "Order #{$order->id} is on its way."]]], 'fcm' => ['notification' => ['title' => 'Order shipped', 'body' => "Order #{$order->id} is on its way."]], 'web' => ['notification' => ['title' => 'Order shipped', 'body' => "Order #{$order->id} is on its way."]], ]);
Laravel용 에이전트 프롬프트
Claude Code, Cursor, GitHub Copilot 등 AI 코딩 에이전트에 붙여 넣으세요. 인스턴스 ID와 엔드포인트가 들어 있고, 시크릿 키는 환경 변수로 남습니다.
Add Hibira push notifications to this Laravel project. Hibira Push sends to iOS (APNs), Android (FCM) and browsers (Web Push) through a Beams-compatible API, so it works with the official Beams server SDKs pointed at the Hibira endpoint (here: pusher/pusher-push-notifications, https://github.com/pusher/push-notifications-php).
Connection details:
- Instance ID: YOUR_INSTANCE_ID
- Endpoint: https://ws.hibira.io
- Secret key: read it from the HIBIRA_PUSH_SECRET_KEY environment variable (server-side only)
What to do:
1. Look at the project first (framework version, package manager, config and env conventions, where similar integrations live) and follow what it already does.
2. Add the HIBIRA_PUSH_* entries to .env and .env.example, the hibira_push block to config/services.php, and the singleton binding in AppServiceProvider::register, always passing the endpoint (without it the SDK talks to pusher.com).
3. If the project uses laravel-notification-channels/pusher-push-notifications, also bind PushNotifications for its PusherChannel with the same options, because the package builds its own client without an endpoint.
4. Add the token route behind the project's existing auth middleware (web session or API guard, whichever the mobile and web clients use); it must refuse a user_id that is not the signed-in user's.
5. Publish from queued jobs or notifications rather than inside the request where possible.
6. Read the instance ID and endpoint from the project's config or environment, and add placeholder entries to .env.example (or its equivalent). Never commit the secret key or send it to a browser or mobile app.
7. Always set the endpoint above. The Pusher Beams SDKs and their defaults point at pusher.com.
8. If YOUR_INSTANCE_ID above is still a placeholder, keep it as a config placeholder and tell me where to fill it in rather than inventing a value.
9. Subscribe test devices to the "hello" interest so the portal's Send a test reaches them.
10. When you are done, list the files you changed and tell me how to check it works: on the Hibira portal app page, Push notifications › Send a test to the hello interest.
Reference setup from the Hibira push notifications guide (adapt it to the project's structure):
Install:
```shell
composer require pusher/pusher-push-notifications
```
Set your push credentials:
```ini
HIBIRA_PUSH_INSTANCE_ID=YOUR_INSTANCE_ID
HIBIRA_PUSH_SECRET_KEY=
HIBIRA_PUSH_ENDPOINT=https://ws.hibira.io
```
Bind the client:
```php
// config/services.php
'hibira_push' => [
'instance_id' => env('HIBIRA_PUSH_INSTANCE_ID'),
'secret_key' => env('HIBIRA_PUSH_SECRET_KEY'),
'endpoint' => env('HIBIRA_PUSH_ENDPOINT'),
],
// app/Providers/AppServiceProvider.php, in register()
$this->app->singleton(\Pusher\PushNotifications\PushNotifications::class, fn () => new \Pusher\PushNotifications\PushNotifications([
'instanceId' => config('services.hibira_push.instance_id'),
'secretKey' => config('services.hibira_push.secret_key'),
'endpoint' => config('services.hibira_push.endpoint'),
]));
```
Add the user token endpoint:
```php
// routes/web.php (or routes/api.php with your API guard)
use Illuminate\Http\Request;
use Pusher\PushNotifications\PushNotifications;
Route::middleware('auth')->get('/push/user-token', function (Request $request, PushNotifications $beams) {
$userId = (string) $request->user()->id;
abort_unless($request->query('user_id') === $userId, 401);
return $beams->generateToken($userId); // {"token": "..."}
});
```
Publish to a signed-in user:
```php
app(\Pusher\PushNotifications\PushNotifications::class)->publishToUsers([(string) $order->user_id], [
'apns' => ['aps' => ['alert' => ['title' => 'Order shipped', 'body' => "Order #{$order->id} is on its way."]]],
'fcm' => ['notification' => ['title' => 'Order shipped', 'body' => "Order #{$order->id} is on its way."]],
'web' => ['notification' => ['title' => 'Order shipped', 'body' => "Order #{$order->id} is on its way."]],
]);
```
공식 Beams 서버 SDK로 Django, Flask, FastAPI 또는 스크립트에서 발송합니다. pusher_push_notifications ↗
설치
pip install pusher_push_notifications관심사에 발송
import os from pusher_push_notifications import PushNotifications beams = PushNotifications( instance_id='YOUR_INSTANCE_ID', secret_key=os.environ['HIBIRA_PUSH_SECRET_KEY'], endpoint='ws.hibira.io', # host only; the SDK always uses https ) beams.publish_to_interests( interests=['hello'], publish_body={ 'apns': {'aps': {'alert': {'title': 'Hello', 'body': 'Hello, world!'}}}, 'fcm': {'notification': {'title': 'Hello', 'body': 'Hello, world!'}}, 'web': {'notification': {'title': 'Hello', 'body': 'Hello, world!'}}, }, )사용자 토큰 엔드포인트 추가
# Flask: GET /push/user-token?user_id=..., for a signed-in user only def push_user_token(): user_id = str(current_user.id) if request.args.get('user_id') != user_id: abort(401) return beams.generate_token(user_id) # {'token': '...'}로그인한 사용자에게 발송
beams.publish_to_users( user_ids=['user-1'], publish_body={ 'apns': {'aps': {'alert': {'title': 'Order shipped', 'body': 'Order #1024 is on its way.'}}}, 'fcm': {'notification': {'title': 'Order shipped', 'body': 'Order #1024 is on its way.'}}, 'web': {'notification': {'title': 'Order shipped', 'body': 'Order #1024 is on its way.'}}, }, )
Python용 에이전트 프롬프트
Claude Code, Cursor, GitHub Copilot 등 AI 코딩 에이전트에 붙여 넣으세요. 인스턴스 ID와 엔드포인트가 들어 있고, 시크릿 키는 환경 변수로 남습니다.
Add Hibira push notifications to this Python project. Hibira Push sends to iOS (APNs), Android (FCM) and browsers (Web Push) through a Beams-compatible API, so it works with the official Beams server SDKs pointed at the Hibira endpoint (here: pusher_push_notifications, https://github.com/pusher/push-notifications-python).
Connection details:
- Instance ID: YOUR_INSTANCE_ID
- Endpoint: https://ws.hibira.io
- Secret key: read it from the HIBIRA_PUSH_SECRET_KEY environment variable (server-side only)
What to do:
1. Look at the project first (framework version, package manager, config and env conventions, where similar integrations live) and follow what it already does.
2. Create one module that builds PushNotifications from environment variables (or the framework's settings), always with endpoint set to the host from the reference (without it the SDK talks to pusher.com).
3. If the app has signed-in users, add the token view or route in the project's framework behind its existing login check; it must refuse a user_id that is not the signed-in user's.
4. Read the instance ID and endpoint from the project's config or environment, and add placeholder entries to .env.example (or its equivalent). Never commit the secret key or send it to a browser or mobile app.
5. Always set the endpoint above. The Pusher Beams SDKs and their defaults point at pusher.com.
6. If YOUR_INSTANCE_ID above is still a placeholder, keep it as a config placeholder and tell me where to fill it in rather than inventing a value.
7. Subscribe test devices to the "hello" interest so the portal's Send a test reaches them.
8. When you are done, list the files you changed and tell me how to check it works: on the Hibira portal app page, Push notifications › Send a test to the hello interest.
Reference setup from the Hibira push notifications guide (adapt it to the project's structure):
Install:
```shell
pip install pusher_push_notifications
```
Publish to an interest:
```python
import os
from pusher_push_notifications import PushNotifications
beams = PushNotifications(
instance_id='YOUR_INSTANCE_ID',
secret_key=os.environ['HIBIRA_PUSH_SECRET_KEY'],
endpoint='ws.hibira.io', # host only; the SDK always uses https
)
beams.publish_to_interests(
interests=['hello'],
publish_body={
'apns': {'aps': {'alert': {'title': 'Hello', 'body': 'Hello, world!'}}},
'fcm': {'notification': {'title': 'Hello', 'body': 'Hello, world!'}},
'web': {'notification': {'title': 'Hello', 'body': 'Hello, world!'}},
},
)
```
Add the user token endpoint:
```python
# Flask: GET /push/user-token?user_id=..., for a signed-in user only
def push_user_token():
user_id = str(current_user.id)
if request.args.get('user_id') != user_id:
abort(401)
return beams.generate_token(user_id) # {'token': '...'}
```
Publish to a signed-in user:
```python
beams.publish_to_users(
user_ids=['user-1'],
publish_body={
'apns': {'aps': {'alert': {'title': 'Order shipped', 'body': 'Order #1024 is on its way.'}}},
'fcm': {'notification': {'title': 'Order shipped', 'body': 'Order #1024 is on its way.'}},
'web': {'notification': {'title': 'Order shipped', 'body': 'Order #1024 is on its way.'}},
},
)
```
공식 Beams 서버 SDK와 사용자 지정 기본 URL로 Go 서비스에서 발송합니다. push-notifications-go ↗
설치
go get github.com/pusher/push-notifications-go관심사에 발송
import ( "os" pushnotifications "github.com/pusher/push-notifications-go" ) beams, err := pushnotifications.New("YOUR_INSTANCE_ID", os.Getenv("HIBIRA_PUSH_SECRET_KEY"), pushnotifications.WithCustomBaseURL("https://ws.hibira.io")) if err != nil { return err } publishID, err := beams.PublishToInterests([]string{"hello"}, map[string]interface{}{ "apns": map[string]interface{}{"aps": map[string]interface{}{ "alert": map[string]interface{}{"title": "Hello", "body": "Hello, world!"}}}, "fcm": map[string]interface{}{ "notification": map[string]interface{}{"title": "Hello", "body": "Hello, world!"}}, "web": map[string]interface{}{ "notification": map[string]interface{}{"title": "Hello", "body": "Hello, world!"}}, })사용자 토큰 엔드포인트 추가
// GET /push/user-token?user_id=..., behind your session middleware http.HandleFunc("/push/user-token", func(w http.ResponseWriter, r *http.Request) { userID := currentUserID(r) if userID == "" || r.URL.Query().Get("user_id") != userID { http.Error(w, "unauthorized", http.StatusUnauthorized) return } token, err := beams.GenerateToken(userID) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(token) // {"token": "..."} })로그인한 사용자에게 발송
publishID, err := beams.PublishToUsers([]string{"user-1"}, map[string]interface{}{ "fcm": map[string]interface{}{ "notification": map[string]interface{}{"title": "Order shipped", "body": "Order #1024 is on its way."}}, "apns": map[string]interface{}{"aps": map[string]interface{}{ "alert": map[string]interface{}{"title": "Order shipped", "body": "Order #1024 is on its way."}}}, })
Go용 에이전트 프롬프트
Claude Code, Cursor, GitHub Copilot 등 AI 코딩 에이전트에 붙여 넣으세요. 인스턴스 ID와 엔드포인트가 들어 있고, 시크릿 키는 환경 변수로 남습니다.
Add Hibira push notifications to this Go project. Hibira Push sends to iOS (APNs), Android (FCM) and browsers (Web Push) through a Beams-compatible API, so it works with the official Beams server SDKs pointed at the Hibira endpoint (here: push-notifications-go, https://github.com/pusher/push-notifications-go).
Connection details:
- Instance ID: YOUR_INSTANCE_ID
- Endpoint: https://ws.hibira.io
- Secret key: read it from the HIBIRA_PUSH_SECRET_KEY environment variable (server-side only)
What to do:
1. Look at the project first (framework version, package manager, config and env conventions, where similar integrations live) and follow what it already does.
2. Build one pushnotifications client at startup from environment variables, always with pushnotifications.WithCustomBaseURL (without it the SDK talks to pusher.com), and pass it to the code that publishes.
3. If the service has signed-in users, add the token handler behind the existing session or auth middleware; it must refuse a user_id that is not the signed-in user's.
4. Read the instance ID and endpoint from the project's config or environment, and add placeholder entries to .env.example (or its equivalent). Never commit the secret key or send it to a browser or mobile app.
5. Always set the endpoint above. The Pusher Beams SDKs and their defaults point at pusher.com.
6. If YOUR_INSTANCE_ID above is still a placeholder, keep it as a config placeholder and tell me where to fill it in rather than inventing a value.
7. Subscribe test devices to the "hello" interest so the portal's Send a test reaches them.
8. When you are done, list the files you changed and tell me how to check it works: on the Hibira portal app page, Push notifications › Send a test to the hello interest.
Reference setup from the Hibira push notifications guide (adapt it to the project's structure):
Install:
```shell
go get github.com/pusher/push-notifications-go
```
Publish to an interest:
```go
import (
"os"
pushnotifications "github.com/pusher/push-notifications-go"
)
beams, err := pushnotifications.New("YOUR_INSTANCE_ID", os.Getenv("HIBIRA_PUSH_SECRET_KEY"),
pushnotifications.WithCustomBaseURL("https://ws.hibira.io"))
if err != nil {
return err
}
publishID, err := beams.PublishToInterests([]string{"hello"}, map[string]interface{}{
"apns": map[string]interface{}{"aps": map[string]interface{}{
"alert": map[string]interface{}{"title": "Hello", "body": "Hello, world!"}}},
"fcm": map[string]interface{}{
"notification": map[string]interface{}{"title": "Hello", "body": "Hello, world!"}},
"web": map[string]interface{}{
"notification": map[string]interface{}{"title": "Hello", "body": "Hello, world!"}},
})
```
Add the user token endpoint:
```go
// GET /push/user-token?user_id=..., behind your session middleware
http.HandleFunc("/push/user-token", func(w http.ResponseWriter, r *http.Request) {
userID := currentUserID(r)
if userID == "" || r.URL.Query().Get("user_id") != userID {
http.Error(w, "unauthorized", http.StatusUnauthorized)
return
}
token, err := beams.GenerateToken(userID)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(token) // {"token": "..."}
})
```
Publish to a signed-in user:
```go
publishID, err := beams.PublishToUsers([]string{"user-1"}, map[string]interface{}{
"fcm": map[string]interface{}{
"notification": map[string]interface{}{"title": "Order shipped", "body": "Order #1024 is on its way."}},
"apns": map[string]interface{}{"aps": map[string]interface{}{
"alert": map[string]interface{}{"title": "Order shipped", "body": "Order #1024 is on its way."}}},
})
```
어떤 언어에서든, 터미널에서 빠르게 테스트할 때도: 발송 API는 평범한 HTTPS와 JSON입니다. REST API ↗
관심사에 발송
curl -X POST "https://ws.hibira.io/publish_api/v1/instances/YOUR_INSTANCE_ID/publishes/interests" \ -H "Authorization: Bearer $HIBIRA_PUSH_SECRET_KEY" \ -H "Content-Type: application/json" \ -d '{ "interests": ["hello"], "apns": {"aps": {"alert": {"title": "Hello", "body": "Hello, world!"}}}, "fcm": {"notification": {"title": "Hello", "body": "Hello, world!"}}, "web": {"notification": {"title": "Hello", "body": "Hello, world!"}} }' # {"publishId":"pubid-..."}로그인한 사용자에게 발송
curl -X POST "https://ws.hibira.io/publish_api/v1/instances/YOUR_INSTANCE_ID/publishes/users" \ -H "Authorization: Bearer $HIBIRA_PUSH_SECRET_KEY" \ -H "Content-Type: application/json" \ -d '{"users": ["user-1"], "fcm": {"notification": {"title": "Order shipped", "body": "Order #1024 is on its way."}}}'사용자 삭제
# Unlinks every device of the user, for example when their account is deleted. curl -X DELETE "https://ws.hibira.io/customer_api/v1/instances/YOUR_INSTANCE_ID/users/user-1" \ -H "Authorization: Bearer $HIBIRA_PUSH_SECRET_KEY"
curl / HTTP용 에이전트 프롬프트
Claude Code, Cursor, GitHub Copilot 등 AI 코딩 에이전트에 붙여 넣으세요. 인스턴스 ID와 엔드포인트가 들어 있고, 시크릿 키는 환경 변수로 남습니다.
Add Hibira push notifications to this curl / HTTP project. Hibira Push sends to iOS (APNs), Android (FCM) and browsers (Web Push) through a Beams-compatible API, so it works with the official Beams server SDKs pointed at the Hibira endpoint (here: REST API, https://hibira.io/guides/push-notifications).
Connection details:
- Instance ID: YOUR_INSTANCE_ID
- Endpoint: https://ws.hibira.io
- Secret key: read it from the HIBIRA_PUSH_SECRET_KEY environment variable (server-side only)
What to do:
1. Look at the project first (framework version, package manager, config and env conventions, where similar integrations live) and follow what it already does.
2. Use the HTTP client the project already has; send JSON with Authorization: Bearer and the secret key from the environment.
3. A publish takes up to 100 interests or 1,000 user IDs; split larger audiences across several requests and retry a 429 response after the Retry-After delay.
4. User tokens for the client SDKs are HS256 JWTs signed with the secret key, with sub set to the user ID, iss set to https://<instance ID>.pushnotifications.pusher.com and exp in the future; prefer a maintained JWT library to build them.
5. Read the instance ID and endpoint from the project's config or environment, and add placeholder entries to .env.example (or its equivalent). Never commit the secret key or send it to a browser or mobile app.
6. Always set the endpoint above. The Pusher Beams SDKs and their defaults point at pusher.com.
7. If YOUR_INSTANCE_ID above is still a placeholder, keep it as a config placeholder and tell me where to fill it in rather than inventing a value.
8. Subscribe test devices to the "hello" interest so the portal's Send a test reaches them.
9. When you are done, list the files you changed and tell me how to check it works: on the Hibira portal app page, Push notifications › Send a test to the hello interest.
Reference setup from the Hibira push notifications guide (adapt it to the project's structure):
Publish to an interest:
```shell
curl -X POST "https://ws.hibira.io/publish_api/v1/instances/YOUR_INSTANCE_ID/publishes/interests" \
-H "Authorization: Bearer $HIBIRA_PUSH_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"interests": ["hello"],
"apns": {"aps": {"alert": {"title": "Hello", "body": "Hello, world!"}}},
"fcm": {"notification": {"title": "Hello", "body": "Hello, world!"}},
"web": {"notification": {"title": "Hello", "body": "Hello, world!"}}
}'
# {"publishId":"pubid-..."}
```
Publish to a signed-in user:
```shell
curl -X POST "https://ws.hibira.io/publish_api/v1/instances/YOUR_INSTANCE_ID/publishes/users" \
-H "Authorization: Bearer $HIBIRA_PUSH_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"users": ["user-1"], "fcm": {"notification": {"title": "Order shipped", "body": "Order #1024 is on its way."}}}'
```
Delete a user:
```shell
# Unlinks every device of the user, for example when their account is deleted.
curl -X DELETE "https://ws.hibira.io/customer_api/v1/instances/YOUR_INSTANCE_ID/users/user-1" \
-H "Authorization: Bearer $HIBIRA_PUSH_SECRET_KEY"
```
4. 로그인한 사용자
한 사람이 쓰는 모든 기기로 보내려면 각 기기를 자체 사용자 ID에 연결하세요. 클라이언트 SDK는 ?user_id=…를 붙여 토큰 엔드포인트를 호출하고, 엔드포인트는 요청이 그 로그인한 사용자에게서 왔는지 확인한 뒤 시크릿 키로 generateToken이 만든 토큰을 돌려줍니다(모든 Beams 서버 SDK에 있습니다). 그다음 관심사 대신 사용자 ID로 발송하세요. 사용자를 삭제하면 그 사용자의 모든 기기 연결이 해제됩니다.
사용자가 로그아웃하면 stop을 호출해, 같은 기기의 다음 사용자가 그 사람의 알림을 받지 않게 하세요.
5. 테스트 전송
앱 페이지의 푸시 알림 › 테스트 전송에서 관심사(위 스니펫에서는 hello), 제목, 본문을 입력하고 테스트 전송을 클릭하세요. 그 관심사를 구독한 기기에 몇 초 안에 도착하며, 구독자 미터에 등록된 기기와 브라우저 수가 표시됩니다.
문제 해결
- 기기나 브라우저가 구독자에 나타나지 않음
- 클라이언트가 이 앱의 인스턴스 ID와 엔드포인트로 start를 호출하는지, 사용자가 알림을 허용했는지 확인하세요. Android에서는 google-services.json이 업로드한 서비스 계정과 같은 Firebase 프로젝트의 것이어야 합니다.
- iPhone과 iPad에 아무것도 오지 않음
- APNs 환경은 빌드와 일치해야 합니다. Xcode에서 실행한 빌드는 개발(샌드박스), TestFlight와 App Store는 프로덕션입니다. 번들 ID가 앱과 정확히 같아야 하고, 앱 타깃에 Push Notifications 기능이 켜져 있어야 합니다.
- start()가 “service worker missing”으로 실패함
- /service-worker.js를 사이트 루트에 두고 HTTPS로 제공하며, 웹 가이드의 importScripts 줄을 넣으세요. 하위 폴더의 서비스 워커는 그 폴더만 제어합니다.
- iPhone의 Safari가 권한을 묻지 않음
- iOS·iPadOS 16.4 이상의 Web Push는 사이트를 홈 화면에 추가한 뒤에만 동작하며, 권한 요청은 탭으로 시작해야 합니다.
- 서버 SDK가 여전히 pusher.com에 연결하거나 http로 실패함
- endpoint 옵션을 설정하세요. Node.js SDK는 beams.protocol = 'https'도 필요하고, Go SDK는 WithCustomBaseURL을 사용합니다.
- 발송이 401을 반환함
- 서버가 잘못된 시크릿 키나 유예 기간이 지난 교체 전 키를 쓰고 있습니다. 앱 페이지에서 현재 키를 복사하세요.
- 발송이 429를 반환함
- 플랜이 허용하는 것보다 빠르게 발송하고 있습니다. Retry-After만큼 기다리고, 하나씩 요청하는 대신 한 번의 발송에 관심사 최대 100개 또는 사용자 최대 1,000명을 지정하세요.
- 기기 등록이 402를 반환함
- 앱이 플랜의 구독자 한도에 도달했습니다. 플랜을 업그레이드하거나, 떠난 사용자를 삭제해 그 기기를 제거하세요.
- setUserId가 실패함
- 토큰 엔드포인트는 요청받은 user_id에 대해 이 앱의 시크릿 키로 generateToken이 반환한 JSON을 200으로 응답해야 합니다. 다른 사용자와 연결된 기기는 먼저 stop을 호출해야 합니다.
Pusher Beams에서 옮겨 오시나요? 클라이언트 SDK 패키지를 저희 것으로 바꾸고, 서버 SDK에 엔드포인트를 설정하고, APNs 키와 FCM 서비스 계정을 업로드한 뒤, 사용자가 앱을 업데이트할 때까지 두 서비스 모두로 발송하세요. 기기는 처음 시작할 때 다시 등록됩니다. Pusher에서 이전하기 →