Notificaciones push enriquecidas
Aprende a configurar notificaciones push enriquecidas para el SDK de Braze.
Requisitos previos
Antes de poder utilizar esta característica, tendrás que integrar el SDK de Swift Braze. También tendrás que configurar las notificaciones push.
Configuración de notificaciones push enriquecidas
Paso 1: Crear una extensión de servicio
Para crear una extensión del servicio de notificación, ve a Archivo > Nuevo > Destino en Xcode y selecciona Extensión del servicio de notificación.
Asegúrate de que la opción Incrustar en la aplicación está activada para incrustar la extensión en tu aplicación.
Paso 2: Configuración de la extensión del servicio de notificación
Una extensión del servicio de notificación es un binario propio que se incluye con tu aplicación. Debe configurarse en el Portal del Desarrollador de Apple con su propio ID de aplicación y perfil de aprovisionamiento.
El ID del paquete de la extensión del servicio de notificación debe ser distinto del ID del paquete de tu aplicación principal. Por ejemplo, si el ID del paquete de tu aplicación es com.company.appname
, puedes utilizar com.company.appname.AppNameServiceExtension
para la extensión de tu servicio.
Paso 3: Integración de notificaciones push enriquecidas
Para una guía paso a paso sobre la integración de notificaciones push enriquecidas con BrazeNotificationService
, consulta nuestro tutorial.
Para ver un ejemplo, consulta el uso en NotificationService
de nuestra aplicación Ejemplos.
Añadir el framework de notificaciones push enriquecidas a tu aplicación
Después de seguir la guía de integración de Swift Package Manager, añade BrazeNotificationService
a tu Notification Service Extension
haciendo lo siguiente:
-
En Xcode, en marcos y bibliotecas, selecciona el ícono añadir para añadir un framework.
-
Selecciona el marco “BrazeNotificationService”.
Añade lo siguiente a tu archivo de bibliotecas:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
target 'YourAppTarget' do
pod 'BrazeKit'
pod 'BrazeUI'
pod 'BrazeLocation'
end
target 'YourNotificationServiceExtensionTarget' do
pod 'BrazeNotificationService'
end
# Only include the below if you want to also integrate Push Stories
target 'YourNotificationContentExtensionTarget' do
pod 'BrazePushStory'
end
Para obtener instrucciones sobre cómo poner en práctica las historias push, consulta la documentación.
Tras actualizar el archivo de bibliotecas, ve al directorio de tu proyecto de aplicación Xcode dentro de tu terminal y ejecuta pod install
.
Para añadir BrazeNotificationService.xcframework
a tu Notification Service Extension
, consulta Integración manual.
Utilizar tu propia UNNotificationServiceExtension
Si necesitas utilizar tu propia UNNotificationServiceExtension, puedes llamar en su lugar a brazeHandle
en tu método didReceive
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import BrazeNotificationService
import UserNotifications
class NotificationService: UNNotificationServiceExtension {
override func didReceive(
_ request: UNNotificationRequest,
withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void
) {
if brazeHandle(request: request, contentHandler: contentHandler) {
return
}
// Custom handling here
contentHandler(request.content)
}
}
Paso 4: Crear una notificación enriquecida en tu panel de control
Tu equipo de marketing también puede crear notificaciones enriquecidas desde el panel. Crea una notificación push a través del compositor push y simplemente adjunta una imagen o GIF, o proporciona una URL que aloje una imagen, GIF o video. Ten en cuenta que los activos se descargan al recibir las notificaciones push, por lo que debes prever grandes picos sincrónicos de solicitudes si alojas tus contenidos.
Prerequisites
Before you can use this feature, you’ll need to integrate the Cordova Braze SDK. You’ll also need to set up push notifications.
Setting up rich push notifications
Step 1: Create a notification service extension
In your Xcode project, create a notification service extension. For a full walkthrough, see iOS Rich Push Notifications Tutorial.
Step 2: Add a new target
Open your Podfile and add BrazeNotificationService
to the notification service extension target you just created. If BrazeNotificationService
is already added to a target, remove it before continuing. To avoid duplicate symbol errors, use static linking.
1
2
3
4
target 'NOTIFICATION_SERVICE_EXTENSION' do
use_frameworks! :linkage => :static
pod 'BrazeNotificationService'
end
Replace NOTIFICATION_SERVICE_EXTENSION
with the name of your notification service extension. Your Podfile should be similar to the following:
1
2
3
4
target 'MyAppRichNotificationService' do
use_frameworks! :linkage => :static
pod 'BrazeNotificationService'
end
Step 3: Reinstall your CocoaPods dependencies
In the terminal, go to your project’s iOS directory and reinstall your CocoaPod dependencies.
1
2
cd PATH_TO_PROJECT/platform/ios
pod install
Prerequisites
Before you can use this feature, you’ll need to integrate the React Native Braze SDK. You’ll also need to set up push notifications.
Using Expo to enable rich push notifications
For the React Native SDK, rich push notifications are available for Android by default.
To enable rich push notifications on iOS using Expo, configure the enableBrazeIosRichPush
property to true
in your expo.plugins
object in app.json
:
1
2
3
4
5
6
7
8
9
10
11
12
13
{
"expo": {
"plugins": [
[
"@braze/expo-plugin",
{
...
"enableBrazeIosRichPush": true
}
]
]
}
}
Lastly, add the bundle identifier for this app extension to your project’s credentials configuration: <your-app-bundle-id>.BrazeExpoRichPush
.