question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Push notifications in builds

See original GitHub issue

Push notifications in production builds

Hey. I have an issue with push notification in the production builds of an app. I have tested many things including to switch from my own build server to expos server but that didn’t help either. With the expo app it gets the token, but with a production build it just does nothing.

Used code to get the token

pushKeyGet = async () => {
        const { status: existingStatus } = await Permissions.askAsync(Permissions.NOTIFICATIONS)
        let finalStatus = existingStatus

        if (finalStatus !== 'granted') {
            return Alert.alert("Fehler", "Ohne die Zustimmung können wir Ihnen keine Nachrichten schicken.");
        }

        let token = await Notifications.getExpoPushTokenAsync()
        await this.storeData(token, "@ep/notif/token")

        fetch(config.apiserver + "/addPushKey", {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({
                token: token
            })
        }).then(result => result.json()).then(async res => {
            if (res.request.status != "SUCCESS") {
                await this.removeData("@ep/notif")
                await this.removeData("@ep/notif/token")
                return Alert.alert("Fehler", "Ein unbekannter Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.")
            }
        }).catch(async e => {
            await this.removeData("@ep/notif")
            await this.removeData("@ep/notif/token")
            return Alert.alert("Fehler", "Ein unbekannter Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.")
        })
    }

Repo

The source code of the app is private but I can give you access to the part of the app, that makes problems.

Testing

I only tested the build on Android.

Building

I am building with turtle-cli but using the normal expo-cli to build didn’t change anything.

Many thanks in advance Fabian

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
fabianneufangcommented, Jun 23, 2020

Hey @AdamJNavarro, I made set the token through the command and it worked. Thank you so much for your help and your time.

Have a nice day and safe Fabian

1reaction
fabianneufangcommented, Jun 23, 2020

Or do I have to upload like this?

expo push:android:upload --api-key <key>

Thank you Fabian

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Ultimate Guide To Push Notifications For Developers
Messages should be timely, relevant, and precise. · Use emojis, they tend to help CTR. · Make sure your content is valuable. ·...
Read more >
What You Must Know To Build Savvy Push Notifications
A great push notification is three things: timely, personal and actionable. Evolution of Push Notifications. Before sharing tactics, Weiss summarizes the ...
Read more >
Push Notifications: Why You Want Them & How to Build Them ...
Common Strategies for Push Notifications · Start by leveraging your existing audience and find ways to incentivize them to opt-in for your push ......
Read more >
Codelab: Build a push notification server - web.dev
A step-by-step interactive tutorial that shows you how to build a server that manages push notification subscriptions and sends web push ...
Read more >
Standard Push Notifications Tutorial - BuildFire University
Learn how to use our Push Notification system which allows you to send notifications to all users, notification groups, and custom segments.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found