0.9 C
New York
Saturday, December 21, 2024

ios – Firebase Messaging doesn’t ship Matter Message


I’m attempting to ship push notifications from vs code (firebase admin server) to my iOS machine utilizing Firebase matters. I adopted each step within the Google tutorial and once I run the python code no message is shipped to my iOS machine and nothing even seems within the Firebase Messaging dashboard and I get this output:

Efficiently despatched message: initiatives//messages/

In my swift app, on my actual iPhone machine (iOS 18) I added the app delegate under and I examined it and a FCM token is efficiently generated. After the FCM token is generated within the delegate operate, I name Messaging.messaging().subscribe(toTopic: "information") { error in which is profitable and I get no error.

On my python firebase admin server I authenticate with a service json file (I do know this works as a result of I can write/learn from the database), I am going to embrace a picture under for the permissions on this service account from IAM. Additionally If I take the FCM token that my iPhone generates and attempt to ship a Message on to the token then I get this error:

requests.exceptions.HTTPError: 401 Consumer Error: Unauthorized for url: https://fcm.googleapis.com/v1/initiatives/xbot-fwerge/messages:ship firebase_admin._messaging_utils.ThirdPartyAuthError: Auth error from APNS or Internet Push Service

I might admire any assist getting these firebase push notifications working.

class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate, UNUserNotificationCenterDelegate {
    func software(
        _ software: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        FirebaseApp.configure()

        Messaging.messaging().delegate = self

        UNUserNotificationCenter.present().delegate = self
        let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
        UNUserNotificationCenter.present().requestAuthorization(choices: authOptions) { _, _ in }
        software.registerForRemoteNotifications()

        return true
    }

    func software(
        _ software: UIApplication,
        didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Information
    ) {
        Messaging.messaging().apnsToken = deviceToken
    }

    func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) { }
}
import firebase_admin
from firebase_admin import messaging, credentials

cred = credentials.Certificates("credsAhmed.json")
firebase_admin.initialize_app(cred)

message = messaging.Message(
    notification=messaging.Notification(
        title = "New Launch",
        physique = "Nike Ebook 1 The Nightmare Earlier than Christmas",
    ),
    subject="information",
)

response = messaging.ship(message)
print('Efficiently despatched message:', response)

image

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles