We have a really weird problem with the remote notifications on iPhone. Device just doesn't receive remote notifications however registration works fine. We checked all certificates and also provisioning profile, also tried to send test notification directly from Azure, the same result as we send with our api. When app is installed from HockeyApp notifications works fine. In debug DidReceiveRemoteNotification method is just not called.
public override async void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
// Opened by push notification.
if (application.ApplicationState == UIApplicationState.Background || application.ApplicationState == UIApplicationState.Inactive)
{
// Make userInfo readable.
PushNotification notification = CrossDevice.Current.ConvertToNotification(userInfo);
}
// Process notification so we can attach to it's received event.
CrossAzurePushNotifications.Platform.ProcessNotification(userInfo);
// No data is altered.
completionHandler(UIBackgroundFetchResult.NoData);
}
Note: we are using AzurePushNotifications plugin
xamarin forum question
You should use the 'sandbox' for testing with the debugger attached. See this link or this link for more information about sandbox vs production.
Please also note that switching from production to sandbox in Azure NotificationHub does not always work. Best solution is to create a separate notification hub for test and production.
You need two Notifications Hub: one for testing and one for production.
If you are developing and running the App from Xcode, you have to use the testing Hub with a testing certificate and when you want to upload it to the Apple Store o TestFlight, you have to change the URL and use the Production Hub. If not, there is not woing to work.
You need different certificates, you can check the process here: https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-ios-apple-push-notification-apns-get-started
Here is when you decide what kind of certificate you have to choose: https://learn.microsoft.com/en-us/azure/includes/media/notification-hubs-enable-apple-push-notifications/notification-hubs-appid-create-cert.png
Related
I have created an independent watchkitapp in XCode, installed in apple watch and successfully sent push notification without errors from Pusher app (also in node-apn) but the notification does not arrive in app. (Tried another app for iOS and remote push notification successfully received in iOS app)
These are the steps i took
In my watchkitapp I did WKExtension.shared().registerForRemoteNotifications() and took the device token
UNUserNotificationCenter.current().requestAuthorization and allowed push notification on apple watch. ofcourse I set UNUserNotificationCenter.current().delegate to the InterfaceController (I tried Local Notification and local notifications display normally on the watch)
On XCode watchkitapp.watchkitextension I added Push Notification on capabilities
In Apple Developer page I created app id mirroring the watchkitapp bundle (not the watchkitextension one). In my case apple automatically created App Id in the server but I removed and recreated it to make sure
Checked the Apple Push Notification service and generated Development SSL Cert
Downloaded the Development SSL Cert and installed in keychain
Opened the Pusher app and selected the installed Development SSL Cert from the list. Ran the apple watch app and obtained the Token Id... sent the payload and it says the payload is sent
Tried to restart mac, iphone, apple watch, unpairing apple watch, reinstalling app but the result is the same... push is sent but does not receive in apple watch
anybody can help me how can I fix this?
Finally, I got this successfully. I use node-apn to send from server.
Here are the worth noticing things:
create app id of the watchkitapp bundle in Apple Developer page
install the latest version of: node-apn,
"dependencies": {
"apn": "git+https://github.com/node-apn/node-apn.git#3.0.0",
[...]
}
should set apns-push-type
notification.pushType
(Required when delivering notifications to devices running iOS 13 and later, or watchOS 6 and later. Ignored on earlier system versions.)
The type of the notification. The value of this header is alert or background. Specify alert when the delivery of your notification displays an alert, plays a sound, or badges your app's icon. Specify background for silent notifications that do not interact with the user.
The value of this header must accurately reflect the contents of your notification's payload. If there is a mismatch, or if the header is missing on required systems, APNs may delay the delivery of the notification or drop it altogether.
Is there a way in Notification hub to preview the push notification on simulators/devices before they are pushed to real user's devices? if not, what approach can be utilized here?
Thanks,
Vineet
At this time a preview feature is not available on Azure Notification hub.You can leave your feedback/ feature request on Uservoice. All of the feedback you share in these forums will be monitored and reviewed by the Microsoft engineering teams responsible for building Azure.
You can successfully send push notifications to the Android Emulator. You cannot do the same with the iOS Simulator, due to the fact the Simulator just doesn't allow for it.
You can also use a physical device and using a unique tag, or just logging out a registration or installation ID, you could send a notification directly to your own development devices before sending out to real users. This would allow you to validate behavior and appearances before sending to real users. So basically the same process you would use to validate any kind of UI changes before sending an App update out to users. Try on your own devices first.
Hope that helps! :)
We are currently able to send notifications to specific Android devices through Firebase and I am trying to do the same to IOS devices.
We use POD and have installed
pod 'Firebase/Core'
pod ‘Firebase/Messaging'
We've created an account with Firebase.
I have added the functions that correspond to AppDelegate.swift. After executing the app, I can send notifications from Firebase to all iPhones... but no specific ones.
In production, I have the following
FIRInstanceID.instanceID().setAPNSToken(deviceToken, tape: FIRInstanceIDAPNSTokenType.prod)
Up to here, all good .. but when I try to get the token from a user and then send a notification only to that device... the notification does not arrive
The token is generated without any problems.
if let refreshedToken = FIRInstanceID.instanceID().token() {
print(“InstanceID token: \(refreshedToken)”)
}
From firebase The notification is sent and does not show errors.. but the notification never arrives to the actual device.
Can this be done with Firebase?
Is there any other service that would allow me to do this?
UPDATE
I send message for console
click open image
On Android, Firebase has the luxury of using GCM directly. For Apple, FCM messages need to be sent to Apple Push Notifications.
Make sure you have setup the backend by downloading your APN Key and uploading to your Firebase console:
Download: https://firebase.google.com/docs/cloud-messaging/ios/certs
Upload: Open your Firebase console, click on the gear icon in the upper left, click on Project settings and then the Cloud Messaging Tab. Upload your APN key there.
You should be able to grab the FCM device ID from the debug output console when Firebase starts up (when running the app in debug mode).
You need to update your Firebase pod and add code from this answer to your iOS Application-
Working Firebase Messaging Code for iOS App
I have implement the cloud push notification in iOS using this tutorial iOS push notification tutorial. I have did everything as per the above documentation. No error occur while registration.
In cloud console I can see 1 iOS client clients subscribed to push notifications. Everything seems fine but I cant able to receive the push notification.(even I have restarted my iPhone)
I have sent a push notification from cloud console, but I cant able to receive the push notification in my iPhone. Can anyone help me to solve this issue?
Thanks in Advance
Make sure you have the correct gateway selected on the server side.
The easiest way is to check your mobileprovisioning profile and look for "aps-environment" string. If it is set to "development" you need to use Development (aka Sandbox) gateway. If it is set to "production" you need to use Apple Push Production gateway.
This link might be interesting too:
http://www.pushwoosh.com/programming-push-notification/appcelerator-titanium-push-notification/
There are might be VERY small chance that firewall or router blocking push notifications, but this could be easily detected by switching your device from WiFi to 3G.
It might be an issue with your certificate. You should enable push notifications in the p12 certificate and it should be configured properly in ACS settings. Please refer Appcelerator Cloud Push Notification in iOS
How reliable do you find push notification on the iPhone to be? Does it improve when moving from the sandbox to production server?
I am testing (with the sandbox of course) and have found that notifications are often delayed or not received at all. I am not talking about sending multiple messages and only the last one arriving, as the documentation indicates, but any notification never showing up.
Also, I noticed that if I send a notification with an alert, and then send one with just a badge number, that the second notification will close the alert even after it's already opened. Does this happen between apps as well? For instance, if I send an alert for my app, and then the Facebook app sends a badge, will the Facebook badge close my alert window?
I have no development experience with iPhone apps, but I do know that if you have an unofficial unlocked phone (by using pwnage tool/blackrain etc) then the PUSH notifications might NEVER go through. In fact, it does go through, but to another user's iPhone.
This is because when an iPhone is unofficially network unlocked, it uses the Unique ID of some random individual's iPhone, which causes Push notifications to arrive on either phone (and yes, sometimes also on the unlocked phone it was intended for, but usually not)
Not sure if this is the case with you though, but AFAIK the service is pretty reliable if you follow Apple's rules. :)
The push notification seams better on production. You can always test it using ad-hoc distrbution which uses the production chanel to send the notifications.
I can confirm that production push notifications using
Production Push Notification Certificate
Adhoc Distribution Mobile Provisioning
TestFlight deployment
Production APNS server
works well, no need to publish your app to test production notifications
Production push notifications are not always received. If notifications are machine gunned 1 second apart the first one is received and the rest are not sent, thats my experience.
Where as on a windows phone, they are all received using the windows notification service.