Can't schedule Notifications in Bare iOS Dev Client

I followed the Notifications guide and registered for push (which shows up in Settings > [My App Name] > Notifications) and am getting an ExponentPushToken[XXXXXXXXXXXXXXXX]. However, after sending a sample push I don’t receive it (with the app open or closed):

  const result = await Notifications.scheduleNotificationAsync({
    content: {
      title: 'Test',
      body: 'This is a test.',
    },
    trigger: {
      seconds: 2,
    },
  })

I do see that the notification is scheduled with getAllScheduledNotificationsAsync:

content:
attachments: []
badge: null
body: "This is a test."
categoryIdentifier: ""
data: {}
launchImageName: ""
sound: null
subtitle: null
summaryArgument: ""
summaryArgumentCount: 0
targetContentIdentifier: null
threadIdentifier: ""
title: "Test"
__proto__: Object
identifier: "XXXXXXXXXXXXXXXXXXXXX"
trigger:
class: "UNTimeIntervalNotificationTrigger"
repeats: false
seconds: 2
type: "timeInterval"
__proto__: Object

I have set up eas credentials for both development and production. What’s stranger is that when I send a push with the following cURL, it appears on my phone (but doesn’t get handled in the app):

curl -H "Content-Type: application/json" -X POST "https://exp.host/--/api/v2/push/send" -d '{
                                  "to": "ExponentPushToken[XXXXXXXXXXX]",
                                  "title":"hello",
                                  "body": "world"
                                }'
{"data":{"status":"ok","id":"XXXXXXXXXXXXXX"}}

I built the app to my iPhone 13 Pro using expo run:ios.

Expo v44
Version: eas-cli/2.1.0 darwin-x64 node-v14.19.1

Found the issue: 2 seconds was too short of a time to minimize the app and see the notification. Changing it to 5 seconds works. Now the problem is not being able to track if the app was opened via notification, and getting the data for that notification. The below never prints.

const lastNotificationResponse = Notifications.useLastNotificationResponse()
  useEffect(() => {
    if (!lastNotificationResponse) {
      return
    }

    console.log(
      'Last notification response changed: %o',
      lastNotificationResponse
    )
  }, [lastNotificationResponse])

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.