I'm having as issue with Push Notification to iOS8 device. Everything works fine, but the push is not ringing, only appears on the screen.
I am sending normal pushes via dashboard, in which sound is enabled by default. I tested on iPhone4 (iOS 7.1.2), iPhone5 (iOS 7.0.4), it works fine, but there is no sound on iPhone with iOS 8.
Thanks
edit:
1) We have already modified our code to handle changes push notification registration for ios8. Below is the code snippet:
// Register for Push Notitications, if running iOS 8
if ([application respondsToSelector:#selector(registerUserNotificationSettings:)]) {
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
} else {
// Register for Push Notifications before iOS 8
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}
2) Changing any and all configuration settings doesn't helped either, nor does restarting the device.
Seems like you need this in the request JSON: "sound": "default". Blank used to work, but now needs "default" to use the default sound.
The push register method is changed in iOS 8.Check following possibilities..
1)Check whether you register push notification with sound as this link.
2)Another possibility is sound can be switched off in notification centre.Check in settings-->notification centre-->click on the app and enable sound.
Related
I have developed watchOS app that is only for Apple Watch not integration with iPhone app. From that need to open Apple's default app. such as :
Map
Setting
Health
HeartRate
Sleep
Workout
On iPhone we are open any app via URLScheme or open(url:), but how can we achieve same functionality on watchOS?
on iPhone :
let url = "abc.com"
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(URL, options: nil) { (finished) in
}
}
There is no equivalent on WatchKit. You can use openSystemURL(_:) to make a call or send a message, but You can't open another app.
I have a Flutter application using the firebase-messaging plugin for push notifications.
I register firebase like normal on the client, and I send the fcmToken to the server.
Notifications are created via a python server using aiofcm (which uses firebase's XMPP api). They're created like this:
message = aiofcm.Message(
device_token = t2,
notification = {
"title":notification_title,
"body":notification_body,
"sound":"default",
"tag":link
},
data = {
"click_action": "FLUTTER_NOTIFICATION_CLICK"
},
priority=aiofcm.PRIORITY_HIGH
)
await fcm.send_message(message)
On iOS, notifications pop-up at the top of the screen.
On Android, only the icon shows up in the notification tray - not any of the notification content. This is tested on a Pixel 3 and a OnePlus 6, both running Android P.
Ideally, I would like the notification to be "heads-up" style like this:
Before I was able to accomplish this using data messages and creating the notification programmatically in native android, however I would like to avoid that if possible since data messages don't get delivered on Android if the app is terminated.
To Get heads-up - Notification - Kindly set "alert: true"
Example :
notification = {
"title":notification_title,
"body":notification_body,
"sound":"default",
"alert" : true
"tag":link
},
For heads up notification you will need to use flutter_local_notifications Plugin. It is even recommended in FlutterFire official documentation for notification to show notification in foreground (background notification also supported ofcourse!) and it shows heads up notification by default.
You should check out the firebase.flutter.dev docs it shows how to do this easily with the help of flutter_local_notifiation
you can use background fetch and local notification package for background app running.
So iOS 12 introduced Provisional Authorization for Quiet Notifications that could be seen in Notification Center but not on the Lock screen. It has very cool advantage - you don't need user's approval to send one.
Several articles (smashingmagazine.com, gadgethacks.com, etc.) claim that iOS app will be able to set it's badge if received Provisional Authorization.
Is it really possible to set app badge when app is Provisionally Authorized?
I request authorization using code below:
[[UNUserNotificationCenter currentNotificationCenter]
requestAuthorizationWithOptions:UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionProvisional
completionHandler:^(BOOL granted, NSError *_Nullable error) {
if (granted) {
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}];
I receive token at didRegisterForRemoteNotificationsWithDeviceToken: that could be used to send Push Notification. When I send Push Notification with a payload {"aps":{"alert":"Testing..","badge":1}} I see it in Notification Center but app doesn't get badged.
I tried setting badge using UIApplication.sharedApplication.applicationIconBadgeNumber = 1; but it didn't work as well. It works though if I request regular authorization without providing UNAuthorizationOptionProvisional option.
Same issue here.
It seems, that app badges are off by default for provisional authorization. I couldn't find anything about it in the documentation.
But you can see it in the apps notification settings. The "Badges" switch is off by default:
App badges are also off for provisional notifications in iOS 15.
So this doesn't do anything, unless you go to System Settings and toggle the badges switch.
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .provisional]) { granted, error in
if granted {
DispatchQueue.main.async {
UIApplication.shared.applicationIconBadgeNumber = Int.random(in: 1...1000)
}
}
}
Anyone know a workaround?
I seem to be following the code as suggested by Google Labs to create serviceWorker and have written the code for pushing notifications, yet it does not seem to be showing up. It seems like the push event from the server does reach the browser, however the showNotification function is just ignored.
// in sw.js
self.addEventListener('push', function(event) {
console.log('Push Received'); // this shows up
event.waitUntil(self.registration.showNotification('Hello World'));
// tried self.registration.showNotification('Hello World') but still does not show up
});
Further to check whether the showNotification works I have put the following in the main.js.
//in main.js
console.log(Notification.permission) // shows granted
if (Notification.permission == 'granted') {
console.log('will show notification') // this gets logged
navigator.serviceWorker.getRegistration().then(function(reg) {
Console.log('reached here'); // this too gets logged
reg.showNotification('Hello world!');
});
Lastly I came across this site that some folks have used for testing
https://gauntface.github.io/simple-push-demo/
as well as
https://web-push-book.gauntface.com/demos/notification-examples/
After permitting notifications from this site, I find no notifications appearing using the screen or the given curl command.
I have tried in both Chrome and Firefox and the results are the same. I am using Chrome 68.x and Firefox 61.x on Mac OS 10.13.6
I find that the site I am using has notifications enabled in the Chrome Settings (advanced section). Even clicking on the secure part of the address bar shows that notifications have been set to allow. Is there some other settings that I am missing? Thanks
It was such a silly error. Mac OS X has a notifications settings which was (I think default) set to 'DO NOT DISTURB`. Disabling that showed the push notifications. Thought other folks, like me, who may not have realised this should know.
Some additional advice for Windows 10 desktop users:
Not a -browser- notification - The notifications caused by self.registration.showNotification will not show up in the browser as you might expect. These notifications show up in the Windows Action Center.
Focus Assist - There is a "Focus Assist" setting in Windows that (analogous to the Apple setting mentioned above) determines whether notifications to the Action Center are silent or result in a toast. It does not mention Action Center.
More than one type of "Notification" Just to confuse things, the Windows "Notifications" area is a different, but related feature. The Action Center has an icon in the Taskbar Notification Area. You can read more here.
Dual Monitors - If you have more than one monitor, you will only see the Action Center icon on the task bar of your primary monitor. Further, you will only see the Action Center toast on the primary monitor.
Existing notifications suppress toasts - If the domain for your site is already listed in the Action Center, you won't see an additional toast for new messages. However, you will still see the item your site created in the Action Center. Clear that item, and your next notification will result in a toast.
Check the MacOS notifications settings -> google chrome -> allow notification
NOTE: only for Macbook users
I was looking for a reason I could not see the notifications either. but In windows I had to go to notification settings and for chrome it was disabled. In the browser allowed notifications was enabled.
I have tested to send push notifications with cordova-1.8.1.js and the push plugin together with pushwoosh.com and it work as it should.
I followed this tutorial: http://www.pushwoosh.com/programming-push-notification/push-notification-sdk-integration-for-phonegap/
The push notification is send to my iPhone and it plays the sound and shows the notification when the phone and app is closed, good!
But if I open the phone when the notification is visible then the app is opened as it should...but
the alert that is displayed is saying:
Alert
"push-notification","{\aps\":\sound\":\"default\",\"alert\":\" and then the message....\"}}”
So what is wrong, it should only write the message in the alert and not the rest?
Also if I delete the app with home button and start it again I get another alert saying "registerDevice", "type":"7".....and so on.
2. How can I make this go away?
Any input appeciated, thanks!
Problem solved. Use this and it will only show the message in the alert and nothing else.
document.addEventListener('push-notification', function(event) {
//console.warn('push-notification!: ' + event.notification);
//navigator.notification.alert(JSON.stringify(['push-notification1!', event.notification]));
var notification = JSON.parse(event.notification);
navigator.notification.alert(notification.aps.alert);
//pushNotification.setApplicationIconBadgeNumber(0);
pushNotification.setApplicationIconBadgeNumber(0);
});