Posts

Showing posts with the label Notifications

Android Notification Icon Is A White Circle

Image
Answer : You must use a notification icon with no background. Android will add the circle background. You can set background color with .setColor(context.getResources().getColor(R.color.colorPrimary)) to match your app indentity. Icon inside will remain white and circle will get the color you defined. If your compileSDKversion is above 20 then notification icon should be a white-on-transparent background image. Otherwise the image will be rendered as a white colored image. Please go through the below link too for guidelines to create the icon https://www.google.com/design/spec/patterns/notifications.html and also the notification icon generator. https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.space.trim=1&source.space.pad=0&name=ic_stat_example It seems to be a problem of cache during compilation ... The first image I was using was bad (fully colored), so I think my compilator created somekind of cache on the filename. I...

Android Push Notifications: Icon Not Displaying In Notification, White Square Shown Instead

Answer : Cause: For 5.0 Lollipop "Notification icons must be entirely white". If we solve the white icon problem by setting target SDK to 20, our app will not target Android Lollipop, which means that we cannot use Lollipop-specific features. Solution for target Sdk 21 If you want to support Lollipop Material Icons then make transparent icons for Lollipop and the above version. Please refer following: https://design.google.com/icons/ Please look at http://developer.android.com/design/style/iconography.html, and we'll see that the white style is how notifications are meant to be displayed in Android Lollipop. In Lollipop, Google also suggests that we use a color that will be displayed behind the white notification icon. Refer Link: https://developer.android.com/about/versions/android-5.0-changes.html Wherever we want to add Colors https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setColor(int) Implementation of Noti...

Android Foreground Service Notification Not Showing

Answer : It's because of Android O bg services restrictions. So now you need to call startForeground() only for services that were started with startForegroundService() and call it in first 5 seconds after service has been started. Here is the guide - https://developer.android.com/about/versions/oreo/background#services Like this: //Start service: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { startForegroundService(new Intent(this, YourService.class)); } else { startService(new Intent(this, YourService.class)); } Then create and show notification (with channel as supposed earlier): private void createAndShowForegroundNotification(Service yourService, int notificationId) { final NotificationCompat.Builder builder = getNotificationBuilder(yourService, "com.example.your_app.notification.CHANNEL_ID_FOREGROUND", // Channel id NotificationManagerCompat.IMPORTANCE_LOW); //Low importance prevent visual appearance for this notifica...

Change Push Notifications Programmatically In Swift

Answer : There isn't any way you can change push notifications permission status from program. Also, prompt asking user to allow push notifications can not be shown again and again. You can refer this https://developer.apple.com/library/ios/technotes/tn2265/_index.html. The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day. So using UISwitch to toggle permission status doesn't make any sense unless you use switch status to turn on/off remote notifications from your server. Updated with swift 4 : func switchChanged(sender: UISwitch!) { print("Switch value is \(sender.isOn)") if(sender.isOn){ print("on") UIApplication.shared.registerForRemoteNotifications() } else{ print("...

Android Notifications Triggered By Alarm Manager Not Firing When App Is In Doze Mode

Answer : Adding an intent Flag FLAG_RECEIVER_FOREGROUND https://developer.android.com/reference/android/content/Intent#FLAG_RECEIVER_FOREGROUND prior to calling the broadcast receiver should do the trick Intent intent = new Intent(context, ScheduleAllReceiver.class); intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); PendingIntent scheduleAllPendingIntent = PendingIntent.getBroadcast(context, SCHEDULER_DAILY_ALL, intent, PendingIntent.FLAG_UPDATE_CURRENT); I have faced the similar problems. I tried with work manager but the result was same. When phone is locked and is in doze mode the event are not triggered. But for triggering event at exact time you need to use alarm manager only. It should work even in doze mode. Method to register alarm manger (use set exact time instead of repeating) public static void registerAlarm(Context context){ final int FIVE_MINUTES_IN_MILLI = 300000; final int THIRTY_SECOND_IN_MILLI = 30000; long launchTime = System.currentTimeMill...

Android - Android 4.3: How To Get The Notification History

Image
Answer : This is not a rumor: the notification history is a true feature from Android 4.3, although they don't make any mention of it in their What's New page. The following steps will allow you to take advantage from the Notification History in a vanilla Android Jelly Bean 4.3: Go to your app drawer, then tap the Widgets tab. Scroll until you reach Settings shortcut (1x1) widget. Drag and drop this widget to your home screen . You'll see a screen where you can select the type of settings this shortcut will open. Select Notifications . The shortcut Notifications will be in your home screen , tap it. The screen Notifications shows the notification history we are talking about. In this screen currently active notifications appear in full intensity, while dismissed ones are dimmed. Tapping in each notification from this screen will open the corresponding App info screen, where you'll be able to toggle the option Show notifications as you wish. R...