HTML5 Notification not working in Mobile Chrome

Try the following: navigator.serviceWorker.register(‘sw.js’); Notification.requestPermission(function(result) { if (result === ‘granted’) { navigator.serviceWorker.ready.then(function(registration) { registration.showNotification(‘Notification with ServiceWorker’); }); } }); That is, use ServiceWorkerRegistration»showNotification() not new Notification(). That should work on Android both in Chrome and in Firefox — and on iOS in Safari, too. (The sw.js file can just be a zero-byte file.) One caveat … Read more

Trigger notification weekly Swift 3

You can set your trigger to repeat every monday at 1:05am as follow: import UserNotifications let trigger = UNCalendarNotificationTrigger(dateMatching: DateComponents(hour: 1, minute: 5, weekday: 2), repeats: true) print(trigger.nextTriggerDate() ?? “nil”) let content = UNMutableNotificationContent() content.title = “title” content.body = “body” // make sure you give each request a unique identifier. (nextTriggerDate description) let request = … Read more

iPhone : Daily local notifications

You just need to properly create a NSDate object to be your fire date (time). Instead of using [NSDate dateByAddingTimeInterval: 20], use something like this: NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *components = [[NSDateComponents alloc] init]; [components setDay: 3]; [components setMonth: 7]; [components setYear: 2012]; [components setHour: 6]; [components setMinute: 0]; [components setSecond: 0]; [calendar … Read more

Detect screen on/off from iOS service

You can use Darwin notifications, to listen for the events. I’m not 100% sure, but it looks to me, from running on a jailbroken iOS 5.0.1 iPhone 4, that one of these events might be what you need: com.apple.iokit.hid.displayStatus com.apple.springboard.hasBlankedScreen com.apple.springboard.lockstate Update: also, the following notification is posted when the phone locks (but not when … Read more

How do I show text in android system status bar

I do found a solution, the keyword is overlay with a floating window. int statusBarHeight = 0; int resourceId = getResources().getIdentifier(“status_bar_height”, “dimen”, “android”); if (resourceId > 0) statusBarHeight = getResources().getDimensionPixelSize(resourceId); final WindowManager.LayoutParams parameters = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, statusBarHeight, WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, // Allows the view to be on top of the StatusBar WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, // Keeps … Read more

Send a notification when the app is closed

You can use this service all you need to do is Start this service onStop() in your activity lifecycle. With this code: startService(new Intent(this, NotificationService.class)); then you can create a new Java Class and paste this code in it: public class NotificationService extends Service { Timer timer; TimerTask timerTask; String TAG = “Timers”; int Your_X_SECS … Read more

Cocoa Custom Notification Example

@implementation MyObject // Posts a MyNotification message whenever called – (void)notify { [[NSNotificationCenter defaultCenter] postNotificationName:@”MyNotification” object:self]; } // Prints a message whenever a MyNotification is received – (void)handleNotification:(NSNotification*)note { NSLog(@”Got notified: %@”, note); } @end // somewhere else MyObject *object = [[MyObject alloc] init]; // receive MyNotification events from any object [[NSNotificationCenter defaultCenter] addObserver:object selector:@selector(handleNotification:) … Read more

Updating iOS badge without push notifications

Try this [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1]; To do this through local notifications you have to set the value in applicationIconBadgeNumber UILocalNotification *localNotification = [[UILocalNotification alloc] init]; localNotification.applicationIconBadgeNumber = 1;// set here the value of badge

tech