-
Notifications
You must be signed in to change notification settings - Fork 44
Description
KMPNotifier and Kotlin version:
kmpnotifier version: v1.6.0
kotlin version: 2.2.20
Describe the bug
Push notifications work correctly on Android, but fail on iOS.
On iOS, I get the token but the app cannot receive push notifications, notifications never arrive.
Steps taken:
- Added Background Modes (Remote notifications) and Push Notifications capabilities.
- Configured Firebase with an APNs Authentication Key.
- Implemented didRegisterForRemoteNotificationsWithDeviceToken to set Messaging.messaging().apnsToken.
- I set FirebaseAppDelegateProxyEnabled to NO.
Logs (I'm not using FirebaseInAppMessaging that's why is not enabled):
12.5.0 - [FirebaseInAppMessaging][I-IAM280002] Firebase In App Messaging was not configured with FirebaseAnalytics.
KMPNotifier: FirebaseMessaging: onNewToken is called
Push Notification onNewToken: fzO_Nrbmf0Ghla919Z77Rg:APA91bGjW64W86suU2TyRs6dtSq-ks7SnD6EUptVWgoPwNP8ZqfWze-b37TmBIN3NFA0vzxbNW6ydjPRXOQj79bQaPXfbSDmtgnU-TUc-V1zJH8coUVD-Gw
App is being debugged, do not track this hang
Hang detected: 0.54s (debugger attached, not reporting)
nw_connection_copy_connected_local_endpoint_block_invoke [C2] Client called nw_connection_copy_connected_local_endpoint on unconnected nw_connection
nw_connection_copy_connected_remote_endpoint_block_invoke [C2] Client called nw_connection_copy_connected_remote_endpoint on unconnected nw_connection
nw_connection_copy_protocol_metadata_internal_block_invoke [C2] Client called nw_connection_copy_protocol_metadata_internal on unconnected nw_connection
12.5.0 - [FirebaseInAppMessaging][I-IAM130004] Failed restful api request to fetch in-app messages: seeing http status code as 403 with body as {
"error": {
"code": 403,
"message": "Requests to this API firebaseinappmessaging.googleapis.com method google.internal.firebase.inappmessaging.v1.sdkserving.InAppMessagingSdkServing.FetchEligibleCampaigns are blocked.",
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "API_KEY_SERVICE_BLOCKED",
"domain": "googleapis.com",
"metadata": {
"consumer": "projects/896078909536",
"methodName": "google.internal.firebase.inappmessaging.v1.sdkserving.InAppMessagingSdkServing.FetchEligibleCampaigns",
"service": "firebaseinappmessaging.googleapis.com",
"apiName": "firebaseinappmessaging.googleapis.com"
}
},
{
"@type": "type.googleapis.com/google.rpc.LocalizedMessage",
"locale": "en-US",
"message": "Requests to this API firebaseinappmessaging.googleapis.com method google.internal.firebase.inappmessaging.v1.sdkserving.InAppMessagingSdkServing.FetchEligibleCampaigns are blocked."
}
]
}
}
12.5.0 - [FirebaseInAppMessaging][I-IAM700002] Error happened during message fetching Error Domain=NSURLErrorDomain Code=403 "(null)"
Code:
import SwiftUI
import FirebaseCore
import FirebaseMessaging
import ComposeApp
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FirebaseApp.configure()
AppInitializer.shared.onApplicationStart()
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) async -> UIBackgroundFetchResult {
NotifierManager.shared.onApplicationDidReceiveRemoteNotification(userInfo: userInfo)
return UIBackgroundFetchResult.newData
}
}
@main
struct iOSApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}