expo: [expo-notifications][ios] Error encountered while fetching Expo token, expected an OK response, received: 400

🐛 Bug Report

Summary of Issue

expo-notifications was working perfectly, but now: Error encountered while fetching Expo token, expected an OK response, received: 400

Environment - output of expo diagnostics & the platform(s) you’re targeting

Expo CLI 3.22.3 environment info: System: OS: Windows 10 10.0.18362 Binaries: Node: 14.4.0 - C:\Program Files\nodejs\node.EXE npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD npmPackages: expo: ~38.0.8 => 38.0.8 react: ~16.11.0 => 16.11.0 react-dom: ~16.11.0 => 16.11.0 react-native: https://github.com/expo/react-native/archive/sdk-38.0.1.tar.gz => 0.62.2 react-native-web: ~0.11.7 => 0.11.7

Reproducible Demo

https://docs.expo.io/versions/latest/sdk/notifications/

Steps to Reproduce

expo init notifications-test copy source from demo above

Expected Behavior vs Actual Behavior

Expected to get a token like “ExponentPushToken[blblablalbalblabla]”

Actual behavior

[Unhandled promise rejection: Error: Error encountered while fetching Expo token, expected an OK response, received: 400 (body: "{"errors":[{"code":"API_ERROR","message":"\"value\" must be of type object."}]}").]
* [native code]:null in construct
- node_modules\@babel\runtime\helpers\construct.js:19:9 in _construct
- node_modules\@babel\runtime\helpers\wrapNativeSuper.js:26:22 in Wrapper
* [native code]:null in construct
* http://192.168.15.85:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:107191:321 in _createSuperInternal
- node_modules\@unimodules\react-native-adapter\build\errors\CodedError.js:8:8 in constructor
- node_modules\expo-notifications\build\getExpoPushTokenAsync.js:7:15 in getExpoPushTokenAsync
- node_modules\regenerator-runtime\runtime.js:45:36 in tryCatch
- node_modules\regenerator-runtime\runtime.js:274:29 in invoke
- node_modules\regenerator-runtime\runtime.js:45:36 in tryCatch
- node_modules\regenerator-runtime\runtime.js:135:27 in invoke
- node_modules\regenerator-runtime\runtime.js:145:18 in PromiseImpl.resolve.then$argument_0
- node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:135:14 in _callTimer
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:183:16 in _callImmediatesPass
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:446:30 in callImmediates
* [native code]:null in callImmediates
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:396:6 in __callImmediates
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:144:6 in __guard$argument_0
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:373:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:143:4 in flushedQueue
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 19 (7 by maintainers)

Most upvoted comments

it’s been resolved and works now.

can you try using curl? curl -H "Content-Type: application/json" -X POST "https://exp.host/--/api/v2/push/send" -d '[{ "to": "ExponentPushToken[fIsPA_Hf-SRThRt4sacSx8]", "title": "Original Title", "body": "And here is the body!" }, { "to": "ExponentPushToken[fIsPA_Hf-SRThRt4sacSx8]", "title": "Original Title", "body": "And here is the body!" } ]'

works in terminal using curl and also works well in postman. …but in react app using fetch works well for single token object but for multiple token array it doesn’t work

OK great. So it seems like this is not something wrong with the servers.

It maybe an issue with notifications not being fully supported on web yet, see here: https://docs.expo.io/versions/latest/sdk/notifications/

If that doesn’t solve your issue, the best place to research this further would be the forums: https://forums.expo.io/

Okay sure I will look into it. Thanks for your time and support.