Firebase Cloud Messaging Doesn't Create Push Notifications But Gets Information

Firebase Cloud Messaging Doesn't Create Push Notifications but Gets Information

Add FirebaseAppDelegateProxyEnabled type "Boolean" value "NO" in your info.plist:

info.plist-image

Firebase Doesn't send push notification

Payload structure was not correct for new function "sendMulticast()" .

required payload structrue

let message = {
notification: {
title: notificationTitle,
body: notificationBody,
// clickAction: clickAction,
// sound: 'default',
},
data: notificationData,
android: {
notification: {
sound: 'default'
}
},
apns: {
payload: {
aps: {
"mutable-content": 1,
sound:'default',
}
}
}
};

if (typeof clickAction === 'string' || clickAction !== "") {
message["android"]["notification"]["click_action"] = clickAction;
}
if (typeof imageURL !== "undefined" && imageURL !== null && imageUrl !== "") {
message["android"]["notification"]["imageUrl"] = imageUrl;
}
return message;

ClickAction and Sound is not supported by sendMulticast(), send() etch kind of function

Firebase Cloud Messaging doesn't work only when released

TLDR: I was missing application.registerForRemoteNotifications() in my AppDelegate.swift.

Looks like my AppDelegate.swift would have been helpful to post:

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
let controller : FlutterViewController = window.rootViewController as! FlutterViewController
let flavorChannel = FlutterMethodChannel(name: "flavor", binaryMessenger: controller.binaryMessenger)
flavorChannel.setMethodCallHandler({ (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
result(Bundle.main.infoDictionary?["Flavor"])
})
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}

We had implemented the directions according to the README in the firebase_messaging project (https://pub.dev/packages/firebase_messaging). This necessitated adding if #available lines. Yes, this is only for doing method swizzling, and we weren't (i.e. we didn't have FirebaseAppDelegateProxyEnabled in our Info.plist file), but I stumbled upon Flutter FCM on iOS 14 (they are implementing swizzling), and noticed that they had an extra line in their file: application.registerForRemoteNotifications(). Once I added that line, (on the line before the return), push notifications started working.

I can't send a Firebase Cloud Messaging push notification to my app i followed the steps but got nowhere


  • I had the same problem(Xcode-11.3.1)

  • I'm using the sample code very long time. There was no problem. I could see the token in log. as usual.

  • I used it again last day. I sent a notification and I saw it was successfully but I couldn't receive it with the device.

  • I added Capability -> Push Notifications and Capability -> Background Modes -> Remote Notifications(check)
  • I created APN key and all certificates but it didn't matter.
  • Then I updated Xcode(11.4.1). It is working now. I wrote to explain that the problem is not code or certificate.

    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    print("APNs token retrieved: \(deviceToken)")
    }

This function is important. If you can see this output, you can receive notification successfully:

APNs token retrieved: 32 bytes

Unable to receive IOS notifications from Firebase Console

Go to firebase->Project Settings->Cloud Messaging -> then scroll down to Apple app configuration and make sure you've provided APNs Production Certificate or not, if not then generate production certificate and upload it there. Alternatively i suggest you to upload APNs Authentication Key instead of certificates.

Preview Image

Flutter - firebase FCM messages not working on Testflight release builds at all

Preface:
the issue was mine.

TL;DR
changed only 1 reference of CubeEnvironment to PRODUCTION.


There are multiple locations to change CubeEnvironment:

  • push_notifications_manager.dart#111
  • push_notifications_manager.dart#111
  • call_manager.dart#111

Suggestion to use, even better to add this in your "CallManagerService"'s init() method:

    bool isProduction = bool.fromEnvironment('dart.vm.product');
parameters.environment = isProduction ? CubeEnvironment.PRODUCTION : CubeEnvironment.DEVELOPMENT;

Debugging (process):
The debugging process (being somewhat unfamiliar with Swift & XCode) could have been better. I considered various provisioning profiles, aps-environment settings, etc.

Since the issue only occurred on Testflight, it made debugging alot more challenging and time consuming as uploading a debug build had its own set of issues

Finally I added a bunch of logging, the one that was crucial was the CB-SDK debug entry (when a notification is received):

[
{
"subscription": {
"id": sub id,
"_id": "insert sub id",
"user_id": cube_user_id,
"bundle_identifier": "insert bundle id",
"client_identification_sequence": "insert client id",
"notification_channel_id": 6,
"udid": "insert-uuid",
"platform_id": 1,
"environment": "development",
"notification_channel": {
"name": "apns_voip"
},
"device": {
"udid": "insert-uuid",
"platform": {
"name": "ios"
}
}
}
}
]

specifically, the following entry.

environment": "development

This is due to APS used 2 different push notification environments, each with its own certificates (certificate is assigned to unique URL's where push notifications can come from). This, aps-environment is set to 'production (see on upload Archive screen right before you start uploading) but I'm receiving development environment notifications - that needed fixing.

Reviewing my code, I finally found the issue (and fix mentioned above).



Related Topics



Leave a reply



Submit