N
Novu8mo ago
Voxelli

Expo issue with ios push notification

How do I fix this? The token attached to the subscriber is for IOS device, we are trying to send push notifications and we are successful with android while ios has the below issue We have a self hosted novu and I am not sure whats wrong here.
No description
3 Replies
Ask Inkeep
Ask Inkeep8mo ago
Hi @Voxelli, I'm an AI assistant knowledgeable about Novu. While a team member is able to review this question, I'll look through relevant sources and see if I can provide suggestions. Please tag @Ask Inkeep with any follow-up questions. ----------------------------- While I generate an answer, here are some sources that might be helpful: * How to send PUSH notifications to iOS devices with FCM using Novu * How to send push notifications in an Android app (react native) with FCM and Novu * Push Channel Introduction * [NV-1924] notification failing due to absence of token in case of multiple active push providers ----------------------------- Answer To address the issue with iOS push notifications while being successful with Android, you should ensure a few key steps are correctly implemented for your iOS setup, especially since you're using a self-hosted Novu setup. Here's a structured approach to troubleshooting and potentially fixing the issue: 1. Verify Subscriber Creation and Token Registration: Ensure that the subscriber is correctly created in Novu and that the iOS device token is correctly added to the subscriber's credentials. You can create a subscriber and update their credentials as follows:
curl --location 'https://api.novu.co/v1/subscribers' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: ApiKey <YOUR_API_KEY>' \
--data-raw '{
"subscriberId": "12345678",
"firstName": "Pawan",
"lastName": "Jain",
"email": "[email protected]",
"phone": "+1234567890",
"avatar": "avatar-url",
"locale": "en-US",
"data": {
"isDeveloper": true,
"customKey": "customValue"
}
}'

curl --location 'https://api.novu.co/v1/subscribers' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: ApiKey <YOUR_API_KEY>' \
--data-raw '{
"subscriberId": "12345678",
"firstName": "Pawan",
"lastName": "Jain",
"email": "[email protected]",
"phone": "+1234567890",
"avatar": "avatar-url",
"locale": "en-US",
"data": {
"isDeveloper": true,
"customKey": "customValue"
}
}'

curl --request PUT \
--url https://api.novu.co/v1/subscribers/{subscriber_id}/credentials \
--header 'Content-Type: application/json' \
--header 'Authorization: ApiKey <YOUR_API_KEY>' \
--data '{
"credentials":{
"deviceTokens": ["token1", "token2"]
},
"integrationIdentifier":"<Provider_Identifier>",
"providerId":"fcm"
}'

curl --request PUT \
--url https://api.novu.co/v1/subscribers/{subscriber_id}/credentials \
--header 'Content-Type: application/json' \
--header 'Authorization: ApiKey <YOUR_API_KEY>' \
--data '{
"credentials":{
"deviceTokens": ["token1", "token2"]
},
"integrationIdentifier":"<Provider_Identifier>",
"providerId":"fcm"
}'

(1) 2. Check iOS Device Registration for Push Notifications: Confirm that your iOS app correctly registers for remote notifications and obtains the device token. This involves setting up the appropriate code in your AppDelegate.swift to request authorization for notifications and register for remote notifications:
import UIKit
import FirebaseCore
import FirebaseMessaging

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()

UNUserNotificationCenter.current().delegate = self

let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: { _, _ in }
)

application.registerForRemoteNotifications()

return true
}
}

extension AppDelegate: UNUserNotificationCenterDelegate {

}

import UIKit
import FirebaseCore
import FirebaseMessaging

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()

UNUserNotificationCenter.current().delegate = self

let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: { _, _ in }
)

application.registerForRemoteNotifications()

return true
}
}

extension AppDelegate: UNUserNotificationCenterDelegate {

}

Ask Inkeep
Ask Inkeep8mo ago
(2) 3. Ensure Correct Configuration with FCM and APNs: Verify that your Firebase Cloud Messaging (FCM) and Apple Push Notification service (APNs) configurations are correctly set up. This includes ensuring that the APNs authentication key or certificate is correctly configured in the Firebase Console for your project, and that your iOS app is correctly set up to use APNs with the correct bundle ID. 4. Review Novu and Provider Documentation: Double-check the Novu documentation and any relevant provider documentation (FCM and APNs) to ensure all settings and configurations are correct. This includes reviewing any recent changes or updates that might affect push notification delivery. If after following these steps, you're still experiencing issues with iOS push notifications, you might want to examine any logs or errors provided by Novu, FCM, or APNs for additional clues. Additionally, considering that you have a self-hosted Novu setup, ensure that your server environment meets all Novu's requirements and that there are no network or configuration issues that might impede notification delivery. Should these steps not resolve your issue, it may be beneficial to engage directly with the Novu community or support channels for more targeted assistance, as there could be specific nuances with your setup that require deeper investigation.
Tomer Barnea
Tomer Barnea8mo ago
Hey @Voxelli two question to you, first, do you need any more help here? cc @Pawan Jain . Second, do you find this AI powered answer helpful?
Want results from more Discord servers?
Add your server