Can I control how long Chrome App notifications last? - google-chrome-app

We've got a Chrome app with working notifications, but the notification only lasts a few seconds and then goes away. Our end users are going to want that notification to stay until they dismiss it. Can that be done? We couldn't find anything in the API documentation regarding notification duration.

Update
Since Chrome 50, you can make a notification persist until dismissed with requireInteraction flag:
Indicates that the notification should remain visible on screen until the user activates or dismisses the notification. This defaults to false.
Old answer
You can't make a chrome.notifications notification last forever.
You can sort of control the duration with the priority parameter. From the relevant article (not the main documentation):
Notifications can be assigned a priority between -2 to 2. Priorities < 0 are only shown in the center; priorities > 0 are shown for increasing duration and more high priority notifications can be displayed in the system tray.
Note: if you call update changing the notification's priority, it will be re-shown as needed. You can, in principle, try to exploit that to stay visible.
If you do not need features provided by Rich Notifications, you can use web standard Notification API.
They look similar in Chrome, but do not integrate with the Message Center. As such, they do not disappear unless dismissed by user or programmatically.

Related

How to detect hardware key taps?

I am at a point where I need to detect if any of the hardware buttons was presses when the flutter app is in foreground or when it is open.*
For example, when someone presses a volume or another button (even if it is the power off one) I want to perform some action in my app.
I know that when a flutter app is open and I am looking at the app logs and I tap any hardware button is tapped the lops related to that tap is printed in the logs.
Like when I press Vol down Key Down Tap Detected related logs are printed in logs.
How do can I perform a function when any of the above specified action is performed?
New plugin called Hardware Buttons was released just a few days ago.
It supports volume button events and power button events, which seems like fits your need.
Maybe have a go with this?
You will need find the proper flutter packages to do so.
Any system level call needs to use the platform channel api
https://flutter.io/platform-channels/
Here is the repository
https://pub.dartlang.org/flutter/
Here is an example of a method channel.
https://github.com/flutter/plugins/blob/master/packages/device_info/lib/device_info.dart
Here is an example of a stream listener.
https://github.com/flutter/plugins/tree/master/packages/sensors
The stream listener wasn't really well documented when I tried to grab mic fragments.

Detect "Close" button in local notification

I am programming an app where the user sets a kind of daily alarm where the application shows certain information every day at the same time. I'm try to make this feature with local notifications. My problem is when the user press the close button of the local notification received, because there is no way to detect this event. I have been searching and seems no solution. I just post this question to be sure there is no solution about the "Close" event.
Thank you
did you try do add a repeating notification?
check this property: notif.repeatInterval
you can add a repeating notification, that fires every hour or day or ...

UILocalNotification actions and snoozing

I'm working on a custom app for a client and am still relatively new to iOS development. The app involves setting reminders and I'm using UILocalNotifications. Now from my research the action on the notification will always run the app but I'm really hoping someone can correct me on that. Also from what I've read you are limited to the 'View' or 'Close' options. Ideally I'd love to have 3 buttons on the notification and not have to open the app to perform an action.
I'd like a 'dismiss' option, 'snooze' option, and an 'ok' option that dismisses the notification but runs some code in the background.
I came across a notification related question where somebody suggested opening the app with a modal view and presenting the options from there. Possible, just not as clean, I guess.
Any other ideas or is this what I have to do to achieve my desired functionality? If that's the case is there a way to close the app after I've selected one of my options from the modal view?
Thanks in advance.
That is not possible, as the notification is not created by your app but by the system, so you can't customize the appearance of the notification. (also in iOS 5, the user can choose to display the notifications as banners instead of alerts, which would hide any other button than the view and close button, if that were to be possible).
Secondly there is no way to close your app, as iOS is a user centric system, where the user takes the decision on whether to open or close app, and not the app itself.

iphone badges management through push notifications

we need iphone to increase the badge numeric value on push notification arrival without initializing the application. f.e. a notification with a badge values of 1 arrives and is shown on the app icon. then another notification with badge value of 2 arrives. 2 replaces 1 on the badge, but we would like to make it 1+2=3. is a server side work around is the only way to deal with this issue?
thanks!
Yes, server side work around is the only way..
What value you will send from server will be set to the icon.
what ever value you are sending to app, that value will be displayed on top of App Icon, either the value may be 4 or 90 or 100.. if you want to do like 1+2=3, just increment the badge number dynamically i.e
Present badge number = Present badge number+2;
just pass "badge:+2" to APP , the number increased

Reason for 5 sec delay to show an activity on pressing the home button?

I am facing delay of 5 sec to show an Activity after pressing the HOME key. I had gone through some post and found that after pressing the HOME button, android prevents services and broadcast-receivers from calling startActivity for 5 seconds.
Q1. Can anyone please let me know the reason to happening this delay ?
Q2. When I modified the ActivityManagerService::checkAppSwitchAllowedLocked() to always return true, it avoids checking lock and hence Activity gets shown without any delay. Would it be a good solution to avoid delay or it may cause any wrong effect in other ways ?
I know, it's probably too late (half year passed). However, here is the answer
You won't be able to get this permission on not rooted phone, unless your application is signed with the same keys as system. Android has some permissions like that.
Also, you may be interested to check this question. Starting an activity from a service after HOME button pressed without the 5 seconds delay