Skip to main content

push notification with Expo - React Native APP

Apollo Server:
yarn add expo-server-sdk


import { Expo } from 'expo-server-sdk'

const pushNotification = (pushTokens, body) => {
// Create a new Expo SDK client
let expo = new Expo()

// Create the messages that you want to send to clents
let messages = []
for (let pushToken of pushTokens) {
// Each push token looks like ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]

// Check that all your push tokens appear to be valid Expo push tokens
if (!Expo.isExpoPushToken(pushToken)) {
console.error(`Push token ${pushToken} is not a valid Expo push token`)

// Construct a message (see
to: pushToken,
sound: 'default',
body: body,
data: { withSome: 'data' }

// The Expo push notification service accepts batches of notifications so
// that you don't need to send 1000 requests to send 1000 notifications. We
// recommend you batch your notifications to reduce the number of requests
// and to compress them (notifications with similar content will get
// compressed).
let chunks = expo.chunkPushNotifications(messages)
let tickets = []
;(async () => {
// Send the chunks to the Expo push notification service. There are
// different strategies you could use. A simple one is to send one chunk at a
// time, which nicely spreads the load out over time:
for (let chunk of chunks) {
try {
let ticketChunk = await expo.sendPushNotificationsAsync(chunk)
// NOTE: If a ticket contains an error code in ticket.details.error, you
// must handle it appropriately. The error codes are listed in the Expo
// documentation:
} catch (error) {

export { pushNotification }


firebase for  push notification

Using FCM for Push Notifications

1. Client Setup:
  "android": {
    "googleServicesFile": "./google-services.json",
2. Uploading Server Credentials

expo push:android:upload --api-key <your-token-here>


Popular posts from this blog

Vocabulary Victory - Build vocabulary at your own pace

download links:

iOS: Android:

1. max connection error on mysql, when do the subquery cards in the loop of query of project, move this function to front end => load flashCards: []  from dashboard.js to project-in-row.js
flashCards:async (project, args, { models }) => { /*const cards = await FlashCard.findAll({ where: { projectId: } }) return cards */ return [] }

The Trip to the Pacific Garbage Patch

(My name is M&M) I was thrown into a garbage can after I was used from The Mystical Smoothie Palace.
The wind was blowing and the garbage can was filled past the top, so I got blown off. I started rolling away towards the ocean. On my way to the ocean it was very rough because while I was rolling with the wind about 1 million people stepped on me (It was actually 20 people). I was flattened badly, but luckily I couldn’t feel a thing. A seagull tried to eat me but thought I didn’t taste good enough (thankfully). The wind kept blowing me until… I saw the sea for the first time!!! I’ve only heard tales about it from my old buddies,
but this is better than I ever imagined!!! I can’t wait to get in!!! The wind blew me faster than ever, until I wasn’t rolling anymore, I was flying over the ocean!!! I’m in the ocean!!! The fresh smell!!! I was floating deeper in the ocean as I heard the waves roar faint away. Soon, I couldn’t see the shore, but I still heard voices. I turned around and sa…
3 kids: 2 pre-teens and one teenager.  I am going to use this blog to record my own foot prints in this journey of growth with our three kids as they themselves grow into young adults. 
I will try to share our own experiences in helping them with their academic and extracuuricular endeavors. The goal is to provide some of our insights and hopefully encourage other parents to share their experiences and insights.