How to open Apple's default app from the other app on Apple Watch? - watchkit

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.

Related

Flutter/Firebase - How to get "heads up" notification on Android?

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.

Setting application badge using provisional authorization in iOS 12

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?

How to configure Desktop Notification in Conkeror browser?

How can I enable Desktop Notification for web apps (Slack, for example)?
I didn't find anything about this on Conkeror Wiki, Mailling List or Google :(
Thanks!
To add desktop notification for Conkeror, you need to use the XPCOM nsIPermissionManager interface, for example
var permissionManager = Components.classes["#mozilla.org/permissionmanager;1"]
.getService(Components.interfaces.nsIPermissionManager);
permissionManager.add(
make_uri("http://www.messenger.com/"),
"desktop-notification",
Components.interfaces.nsIPermissionManager.ALLOW_ACTION
);

Not receiving push notifications on Windows Universal App (Windows 8.1), via Pushwoosh

We're using Pushwoosh services to send push notifications to our applications and we've followed the tutorial for Windows 8 (javascript). We were able to have the push notifications working in our application when running on the desktop computer. This is a Windows 8.1 Universal App, so we run the same code for our Windows Phone 8.1 version, which is also in javascript.
In the Windows Phone device the push message is not being received and it often blocks in the "service.subscribeToPushService();" method. Uninstalling the app and running it for the first time seems to work, but after that it just keeps blocking in that method.
Being an universal app, is there any difference between the phone and desk top version in terms of push notifications that we should be aware of?
Are you sure you are using the latest Pushwoosh Windows 8 SDK? If you are using Universal app for Windows/Windows Phone 8.1 you will need to use Pushwoosh Windows 8 (WNS) Pushwoosh SDK for both platforms. It is located here:
https://github.com/Pushwoosh/pushwoosh-windows-8-sdk
The code should be exactly the same for all platforms:
https://github.com/Pushwoosh/pushwoosh-sdk-samples/blob/master/Native/Win8/Win8JS/js/default.js
var service = new PushSDK.NotificationService.getCurrent("YOUR_PUSHWOOSH_APP_ID");
service.ononpushaccepted = function (args) {
//code to handle push notification
//display push notification payload for test only
var md = new Windows.UI.Popups.MessageDialog(args.toString());
md.showAsync()
}
service.ononpushtokenreceived = function (pushToken) {
//code to handle push token
}
service.ononpushtokenfailed = function (error) {
//code to handle push subscription failure
}
service.subscribeToPushService();
Also don't forget to handle launch push notification:
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
showProgress();
if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated)
{
// TODO: This application has been newly launched. Initialize
// your application here.
//Handle start push
PushSDK.NotificationService.handleStartPush(args.detail.arguments);
Also the same information here:
https://community.pushwoosh.com/questions/1801/push-notification-to-windows-81-universal-apps?page=1&focusedAnswerId=1871#1871
You can read this topic here about push notification, there's a section talking about DOS Attacks protection. May something to be with the connection reopening frequency.
Tip: Refrain from opening and closing the connections to the APNs for each push notification that you want to send. Rapid opening and closing of connections to the APNs will be deemed as a Denial-of-Service (DOS) attack and may prevent your provider from sending push notifications to your applications.

No sound in Parse push notification for ios8

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.

Resources