Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ay caramba, clarifying the FORMAT of the deviceToken !! #145

Open
smhk opened this issue Jul 11, 2024 · 1 comment
Open

Ay caramba, clarifying the FORMAT of the deviceToken !! #145

smhk opened this issue Jul 11, 2024 · 1 comment

Comments

@smhk
Copy link

smhk commented Jul 11, 2024

From the home page:

apnProvider.send(note, deviceToken).then( (result) => {
});

In iOS:

    func application(_ application: UIApplication,
                                        didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        sendToOurServer( deviceToken.base64EncodedString() )

That string looks like this

gCP1Obmj2HS666szreBiMa5bPT3I/igmjNKdPgKYrKtknA39NTwqMWxQV7YHYwv1plKQcmbgVDQFQofG5WG2lPMRVcdaChR2YCAvKs/f0p0=

In node:

async function sendNotifs() {
	for (const aBase64Token of global.known_apns_tokens) {
		const aTokenData = Buffer.from(aBase64Token, 'base64').toString('hex')
                ...
		apnProvider.send(note, aTokenData).then((result) => {

That string looks like this

8023f539b9a3d86666770b33ade06231ae5b3d3dc8fe28268cd29d3e0298acab649c0dfd356666316c5057b607630bf5a652907266e05434054287c6e561b694f31155c75a0a147660202f2acfdfd29d

Is that in fact correct - the formula is Buffer.from(aBase64Token, 'base64').toString('hex') ...?

assuming you use base64 (ie ".base64EncodedString()") for your communications from iOS devices.

Thank you!

Copy link

Thanks for opening this issue!

@smhk smhk changed the title Ay caramba, clarifying the FORMAT of the Ay caramba, clarifying the FORMAT of the deviceToken !! Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant