Back

Auth error from APNS or Web Push Service

  • 0
  • React Native
  • Messaging
  • Cloud
faye
25 Aug, 2024, 18:42
TL;DR
Code is provided for updating push targets with Appwrite in a React Native project, showing a successful registration of the target device. Troubleshooting involves checking logs and ensuring the correct setup for Firebase and APNS certificates to avoid the "Auth error from APNS or Web Push Service" message from Appwrite. Make sure to use the correct target ID when sending messages and to include the proper certificates for Apple push notifications in the development and production modes.
faye
25 Aug, 2024, 18:43

This key got me a file, I uploaded this file into firebase:

faye
25 Aug, 2024, 18:43

I also setup in general the team id and app store id

Steven
25 Aug, 2024, 18:44

Firebase?? So you created a firebase messaging provider in Appwrite?

faye
25 Aug, 2024, 18:45

Yes

faye
25 Aug, 2024, 18:45

Right?

faye
25 Aug, 2024, 18:45
faye
25 Aug, 2024, 18:45

got the service key in there too

Steven
25 Aug, 2024, 18:46

So where is Appwrite saying this error?

faye
25 Aug, 2024, 18:46

In messages

faye
25 Aug, 2024, 18:46
Steven
25 Aug, 2024, 18:47

That target id looks a little odd...did you put the Appwrite target id when sending the message?

faye
25 Aug, 2024, 18:49

I tried following this, not entirely sure where the target id is coming from cause i cannot find it back: https://appwrite.io/docs/products/messaging/send-push-notifications

faye
25 Aug, 2024, 18:49

(converted it to react lol)

Steven
25 Aug, 2024, 18:50

How are you sending the message?

faye
25 Aug, 2024, 18:50

From the console

faye
25 Aug, 2024, 18:50

and the console also shows my target correctly:

faye
25 Aug, 2024, 18:50

.. i think

Steven
25 Aug, 2024, 18:51

Ah okay

Steven
25 Aug, 2024, 18:51

Any logs in firebase?

faye
25 Aug, 2024, 18:52

Where do i find these logs?

Steven
25 Aug, 2024, 18:53

🤷‍♂️ lol

faye
25 Aug, 2024, 18:54

I also did a campaign in firebase directly with a random message, that just says completed

faye
25 Aug, 2024, 18:55

doesn't look like firebase has any logging :2HAhaa:

faye
25 Aug, 2024, 18:57

This is my code for the push targets:

TypeScript
export const updatePushTargetWithAppwrite = async (fcmToken: string) => {
  const targetId = await AsyncStorage.getItem('targetId')

  try {
    // Assuming `account` is your Appwrite Account instance
    const session = await account.get()

    if (!session) return // User is not logged in

    if (!targetId) {
      // Create a new push target
      const target = await account.createPushTarget(ID.unique(), fcmToken)
      await AsyncStorage.setItem('targetId', target.$id)
    } else {
      // Update the existing push target
      await account.updatePushTarget(targetId, fcmToken)
    }
  } catch (error) {
    console.error('Failed to update push target in Appwrite:', error)
    Sentry.captureException(error)
  }
}

But I think that seems to work fine, as it registered my iphone as a target

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more