iOS SDK
Announcements And Notifications
Fetch announcements, poll the notification inbox, and let users control iOS push preferences from your app.
Announcements
Announcements are published updates from the Gleam project. Anonymous users can read public announcements. Signed-in users can also receive targeted announcements when their identity matches the audience.
Fetch announcements
let announcements = try await Gleam.shared.fetchAnnouncements()
let latest = try await Gleam.shared.fetchLatestAnnouncements()
for item in announcements {
print(item.title)
}Notification Inbox
Use notification polling when APNs is not enabled, and as a catch-up pass after app launch. The API requires an authenticated SDK session.
Poll notifications
let notifications = try await Gleam.shared.fetchNotifications(
limit: 20,
unreadOnly: false
)
if let notification = notifications.first,
let url = try Gleam.shared.url(forNotification: notification) {
// Open this URL in your existing Gleam Portal presentation flow.
}Push Preferences
The SDK exposes only the iOS push preference values currently supported by Gleam: replies and announcements.
Read and update preferences
let preferences = try await Gleam.shared.getNotificationPreferences()
try await Gleam.shared.setNotificationPreferences(
GleamNotificationPreferences(
notifyIosPushReply: preferences.notifyIosPushReply,
notifyIosPushAnnouncement: true
)
)Returned Models
| Model | Fields |
|---|---|
| GleamAnnouncement | id, title, body, publishedAt |
| GleamNotification | id, kind, title, body, linkPath, projectId, postId, commentId, announcementId, readAt, createdAt |
| GleamNotificationPreferences | notifyIosPushReply, notifyIosPushAnnouncement |