Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/green-planes-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@use-voltra/android': minor
'@use-voltra/android-server': minor
'@use-voltra/expo-plugin': minor
'voltra': minor
---

Add Android ongoing notification support, including richer notification content, remote update flows, and server-side payload rendering APIs. This release also expands the Expo integration and documentation so apps can configure, send, and manage Android ongoing notifications more easily.
34 changes: 32 additions & 2 deletions example/app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"expo": {
"name": "Voltra Example",
"slug": "voltra-example",
"slug": "voltra",
"scheme": "voltra",
"version": "1.0.0",
"orientation": "portrait",
Expand Down Expand Up @@ -56,6 +56,7 @@
}
],
"android": {
"enableNotifications": true,
"widgets": [
{
"id": "voltra",
Expand Down Expand Up @@ -149,6 +150,13 @@
]
}
],
[
"expo-notifications",
{
"color": "#8232FF",
"defaultChannel": "voltra_live_updates"
}
],
"expo-router",
[
"expo-build-properties",
Expand All @@ -158,6 +166,28 @@
}
}
]
]
],
"extra": {
"eas": {
"build": {
"experimental": {
"ios": {
"appExtensions": [
{
"targetName": "VoltraExampleLiveActivity",
"bundleIdentifier": "com.callstackincubator.voltraexample.VoltraExampleLiveActivity",
"entitlements": {
"com.apple.security.application-groups": ["group.callstackincubator.voltraexample"]
}
}
]
}
}
},
"projectId": "531aac5b-d8a5-4263-8ac3-7eaf19e75021"
},
"router": {}
},
"owner": "aitwar"
}
}
7 changes: 7 additions & 0 deletions example/app/testing-grounds/android-ongoing-notification.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

import AndroidOngoingNotificationTestingScreen from '~/screens/testing-grounds/AndroidOngoingNotificationTestingScreen'

export default function AndroidOngoingNotificationTestingPage() {
return <AndroidOngoingNotificationTestingScreen />
}
21 changes: 21 additions & 0 deletions example/eas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"cli": {
"version": ">= 18.5.0",
"appVersionSource": "remote"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal"
},
"production": {
"autoIncrement": true
}
},
"submit": {
"production": {}
}
}
8 changes: 8 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { registerRootComponent } from 'expo'
import { ExpoRoot } from 'expo-router'

import { registerVoltraBackgroundNotifications } from './notifications/registerBackgroundNotifications'
import { registerPushLogging } from './notifications/registerPushLogging'

registerVoltraBackgroundNotifications().catch(() => {})
registerPushLogging().catch((error) => {
console.log('[expo-notifications] Startup registration failed:', error)
})

export function App() {
const ctx = require.context('./app')
return <ExpoRoot context={ctx} />
Expand Down
34 changes: 34 additions & 0 deletions example/notifications/registerBackgroundNotifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as Notifications from 'expo-notifications'
import * as TaskManager from 'expo-task-manager'

import {
handleBackgroundNotificationTask,
VOLTRA_BACKGROUND_NOTIFICATION_TASK,
} from './voltraAndroidOngoingNotificationBackground'

if (!TaskManager.isTaskDefined(VOLTRA_BACKGROUND_NOTIFICATION_TASK)) {
TaskManager.defineTask<Notifications.NotificationTaskPayload>(
VOLTRA_BACKGROUND_NOTIFICATION_TASK,
async ({ data, error, executionInfo }) => {
if (error) {
console.log('[voltra-background-task] Task invocation error:', error)
return
}

console.log('[voltra-background-task] Task invoked:', executionInfo?.eventId ?? 'unknown-event')

await handleBackgroundNotificationTask({ data })
}
)
}

let backgroundTaskRegistration: Promise<null> | null = null

export const registerVoltraBackgroundNotifications = async () => {
if (!backgroundTaskRegistration) {
backgroundTaskRegistration = Notifications.registerTaskAsync(VOLTRA_BACKGROUND_NOTIFICATION_TASK)
}

await backgroundTaskRegistration
console.log('[voltra-background-task] Background notification task registered:', VOLTRA_BACKGROUND_NOTIFICATION_TASK)
}
61 changes: 61 additions & 0 deletions example/notifications/registerPushLogging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import Constants from 'expo-constants'
import * as Notifications from 'expo-notifications'
import { Platform } from 'react-native'

import { ensureOngoingNotificationChannel } from './voltraAndroidOngoingNotificationBackground'

let pushLoggingRegistration: Promise<void> | null = null

const getProjectId = () => {
return Constants.expoConfig?.extra?.eas?.projectId ?? Constants.easConfig?.projectId ?? null
}

export const registerPushLogging = async () => {
if (pushLoggingRegistration) {
return pushLoggingRegistration
}

pushLoggingRegistration = (async () => {
await ensureOngoingNotificationChannel()

const existingPermissions = await Notifications.getPermissionsAsync()
let finalStatus = existingPermissions.status

if (finalStatus !== 'granted') {
const requestedPermissions = await Notifications.requestPermissionsAsync()
finalStatus = requestedPermissions.status
}

if (finalStatus !== 'granted') {
console.log('[expo-notifications] Push permissions not granted:', finalStatus)
return
}

try {
const deviceToken = await Notifications.getDevicePushTokenAsync()
console.log('[expo-notifications] Device push token:', deviceToken)
} catch (error) {
console.log('[expo-notifications] Failed to fetch device push token:', error)
}

const projectId = getProjectId()
if (!projectId) {
console.log('[expo-notifications] Missing EAS projectId; skipping Expo push token fetch.')
return
}

try {
const expoToken = await Notifications.getExpoPushTokenAsync({ projectId })
console.log('[expo-notifications] Expo push token:', expoToken.data)
} catch (error) {
console.log('[expo-notifications] Failed to fetch Expo push token:', error)
}

if (Platform.OS === 'android') {
const channels = await Notifications.getNotificationChannelsAsync()
console.log('[expo-notifications] Android channels:', channels?.map((channel) => channel.id) ?? [])
}
})()

return pushLoggingRegistration
}
Loading
Loading