0

I have a live production AppStore App via flutter, IOS notifications work fine for a while (after the user performs a first login).

Then out of nowhere, they stop being displayed! Sometimes they go "missing" (example: maybe messages don't show, but another type of notification does show). Only when the user forces an FCM token refresh (via log out -> log in) do the notifications start working again...

What would cause the FCM token to "expire" on the APN side? And why does refreshing FCM token immediately fix the issue for the users? Using firebase_messaging: ^13.0.2

FCM code that works, just for a reference as to what I am doing in flutter:

sendNotificationV2(String token, String title, String body,
    Map<String, dynamic>? payload) async {

  var data_back = await http.post(
    Uri.parse('https://fcm.googleapis.com/fcm/send'),
    headers: <String, String>{
      'Content-Type': 'application/json',
      'Authorization': 'key=$SERVER_KEY',
    },
    body: jsonEncode(
      <String, dynamic>{
        'to': token,
        'token': token,
        'notification': <String, dynamic>{'body': body, 'title': title},
        'priority': 'high',
        'data': payload ?? <String, dynamic>{}
      },
    ),
  );

  print("SENT NOTIFICATION FROM V2 METHOD, TOKEN: $token");
  print(data_back);
  print(data_back.body);
  print(data_back.bodyBytes);




}
Petro
  • 3,484
  • 3
  • 32
  • 59

0 Answers0