Reputation: 1301
I've set up push notifications according to this walkthrough: https://www.appcoda.com/firebase-push-notifications/
But when I send a test message from Firebase, it doesn't show up. I followed all the steps, I have valid certificates:
Provisioning Profile set up for push notifications:
Under my App ID it shows that notifications are enabled:
And I have the certificate uploaded to Firebase:
And in my AppDelegate
didFinishLaunchingWithOptions
:
if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
// For iOS 10 data message (sent via FCM
FIRMessaging.messaging().remoteMessageDelegate = self
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
Along with the Firebase callback method in AppDelegate
:
func applicationReceivedRemoteMessage(_ remoteMessage: FIRMessagingRemoteMessage) {
print(remoteMessage.appData)
}
And obviously I have imported:
import UserNotifications
import FirebaseInstanceID
import FirebaseMessaging
I'm not sure why the push notifications are not working, it seems like everything is in place. The only thing out of the ordinary I did was remove the entitlements from Target -> Code Signing, as it was giving me an invalid entitlements error when I tried to run the app. Now that it's removed, the app is running fine. I do have an open question about that separate issue but for now I'll assume that's not the cause of my problems here.
And just to confirm, I don't have to re-download the Google plist after adding notifications? I was using Firebase in my project before adding notifications, so I already have one.
Thanks for any help getting the notifications working!
Upvotes: 2
Views: 2145
Reputation: 850
Try Adding FirebaseAppDelegateProxyEnabled type "Boolean" value "NO" in your info.plist
and maybe add Messaging.messaging().shouldEstablishDirectChannel to true in your AppDelegate
Upvotes: 1
Reputation: 384
Can you check in the capabilities tab if push notifications are enabled. Also, since Xcode 8 you need to add the entitlements file with aps-environment set. If you disable and enable the push notifications from capabilities you will get this file.
Upvotes: 0