Having trouble obtaining a valid Expo push notification token

I'm currently developing a React Native app using Expo but encountering issues with obtaining a valid token, which in turn affects the push notification functionality.

Upon pasting the generated token on , an error message stating "This is not a valid Expo push token." pops up. While notifications function properly on Expo Go, they fail to work on TestFlight.

The code snippet in question is as follows:

import * as Device from "expo-device";
import * as Notifications from "expo-notifications";
import React, { useEffect, useRef, useState } from "react";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
...
... (the remaining code snippet continues)

Answer №1

Figured it out! Make sure to upgrade your app using expo. execute this command: eas update
Simple as that!

Answer №2

I am encountering a similar issue where getting permissions requires including projectId:

token = await Notifications.getExpoPushTokenAsync({
  projectId: Constants.expoConfig.extra.eas.projectId,
});

However, TypeScript cannot find expoConfig in Constants.

[{
    "resource": "/Users/user/code/name_of_app/app/navigaton/AppNavigator.tsx",
    "owner": "typescript",
    "code": "2339",
    "severity": 8,
    "message": "Property 'expoConfig' does not exist on type 'typeof import(\"/Users/user/code/name_of_app/node_modules/expo-constants/build/Constants\")'.",
    "source": "ts",
    "startLineNumber": 57,
    "startColumn": 28,
    "endLineNumber": 57,
    "endColumn": 38
}]`

I attempted hardcoding the projectId, but it did not work either. Here is the documentation page for reference:

*** Update: Issue resolved with updated types

import Constants from "expo-constants"
instead of
import * as Constants from "expo-config"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Incorporate a corner box feature to bring attention to the typed.js functionality

I have successfully integrated typed.js into my project and now I am looking to replicate the highlighted text with an excel-like box in one corner. I've managed to get the text typing out while also adding an SVG for the box in HTML, but I'm hav ...

Troubleshooting a TypeScript Problem with React Context

In my AppContext.tsx file, I have defined the following import React, { useState, createContext } from "react"; import { Iitem } from "../utils/interfaces"; interface AppContext { showModal: boolean; setShowModal: React.Dispatch< ...

How can we stop the page from scrolling after a click?

Upon clicking the link labeled Click Me, the page automatically scrolls back to the top. This behavior is not desired. How can I correct this issue? For example, here is a link to a relevant resource: http://jsfiddle.net/Y6Y3Z/ Regarding the scroll-bar: ...

Developing instance members and methods in JavaScript

After encountering a challenge with creating "private" instance variables in JavaScript, I stumbled upon this discussion. Prior to posing my question, I wanted to provide a thorough overview of the problem. My goal is to showcase a complete example of corr ...

What are the drawbacks of utilizing the onClick function in JavaScript?

What is the rationale behind programmers opting not to use onClick function in Javascript? ...

Is it possible to utilize Webpack 5's ChunkGroup API with several entries?

I am encountering an error message when attempting to upgrade from Webpack 4 to Webpack 5. The error states: Module.entryModule: Multiple entry modules are not supported by the deprecated API (Use the new ChunkGroup API) I have searched for information o ...

AJAX fails to retrieve a result

I've been attempting to grasp the concept of using ajax, but unfortunately I have not been able to receive any response. Here is the HTML code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta ...

Can the current fragment displayed in FragmentStatePagerAdapter be replaced without the need to swipe to other pages first?

After successfully replacing fragments in a FragmentStatePagerAdapter, I realized that the process requires swiping out of the fragment for it to be destroyed and a new fragment to be created. This led me to wonder if it is possible to replace the currentl ...

Troubleshooting the issue with login parameters not being posted correctly through REST requests with

Trying to configure my Demo Login Android Application to authenticate via REST on the server using a login.php app that accesses a local MySQL Database. When executing the REST Query from Insomnia, I provide the following JSON Array: { "email": "< ...

Adjust the tabs to fit perfectly within the container

I am currently facing an issue with my navigation bar. I have placed the <nav> tags within a container set to 100% width. However, when I adjust the height of the container by a certain percentage, the <ul> & <li> elements in the nav ...

The columnFilter plugin in Datatables is failing to initialize

I have a pre-existing table that needs to be customized and initialized properly. <table id="currencies-table" class="table table-striped table-bordered table-hover form-data-table"> <thead> <tr> <th style="width: 10px;" ...

How can I update data in Select2 after it has been initialized?

After initializing select2, I am trying to set an array of data in the following way: var selection = $('#selection').select2({}); selection.data([ {id: 1, text: 'value1'}, {id: 1, text: 'value1'} ]); However, I am encou ...

Transferring files to Django using AJAX

I am struggling with the process of uploading files to django using ajax. The upload is done within a modal window. The Form <div class="modal fade bs-example-modal-lg" id="fileUploadModal" role="dialog" aria-hidden="true"> <div class="modal ...

The expandable row remains open even after filtering the table with JavaScript

An expandable row in the table displays details of rows. I have implemented a JavaScript search and filter function to find specific row content. However, when using the search filter, it successfully shows results but does not expand the details as intend ...

``Are you looking to create multiple canvases in a loop?

I've managed to get this command working exactly as I wanted: http://jsfiddle.net/m1erickson/64BHx/ However, I didn't anticipate how challenging it would be to turn the drawing into reality here: What I attempted to do is illustrated in this li ...

Switch out the smaller thumbnail image with a more enlarged image

Im pretty new to web programming and im working on a site now. In one part of this site, I have collections of 3 pictures. 1 larger one and two smaller thumbnails below it. The goal is to create a way in which i can click on one of the thumbnails and the ...

Error in Javascript: Required variable missing for Sendgrid operation

I am facing an issue while attempting to send an email using sendgrid. Whenever I execute the function, it gives me an error saying "Can't find variable: require". Despite my efforts to search for a solution online, I have not been able to resolve thi ...

Removing an object from nested JSON based on a condition using jQuery with the help of AngularJS

I have a JSON object stored in the variable $scope.bbTreeData. I'm trying to delete any objects where the flag is set to false. While I can navigate through the nested JSON object, I'm unsure how to properly remove the object. Any suggestions? [ ...

There are problems with the developer certificate preventing the installation of the iOS app

Our team has been utilizing a test flight build to submit apps to the IOS iTunes server. Everything was running smoothly until recently when we encountered an error after submitting from Xcode: Error Details~ Could not install The app could not be instal ...

jQuery validation on select box change event

A project I'm working on involves designing a show/hide feature for a div select box using select2 and validating it using the jQuery validation plugin. Everything seems to be working fine, except for one issue I've encountered. When I select an ...