Push notifications android 6.0. Push notifications - what are they? How to enable and disable Push Notifications? Connect to a stable network

Apple is responsible for the correct operation of Push notifications in iOS. Any third party application, if it wants to send notifications to the user, it must use Apple servers for this. The scheme looks like this: the developer will raise his own server, which accesses Apple's Push Notification Service (APNS), which in turn sends notifications to users on their devices.

Therefore, if some specific application does not send you notifications, then the problem lies in the crooked hands of the developer, who cannot properly configure the interaction of his server with APNS. If you stop receiving absolutely all notifications, then try the following instructions.

Exit from account Apple ID

For identification Apple devices uses your Apple ID. This is how the company understands where to send notifications. The first thing to do if you have problems with receiving Push-notifications – sign out and sign in again to your Apple ID. You can do this in “Settings” > “ iTunes Store and App Store."

Reconnect your device to iCloud

A similar step should be repeated with cloud service iCloud, which is responsible for synchronizing data between devices and with Apple servers. You can do this in Settings > iCloud.

Restart device

iOS doesn't have many tools for solving problems, reboot being the main one. Let us remind you that a reboot is different from a regular power off/on. You can restart your device by long pressing the power button and the Home key on older devices and long pressing the power and volume down button on the iPhone 7 and iPhone 7 Plus.

Check Do Not Disturb Mode

If the system is set to Do Not Disturb mode, you will not hear notifications in specified time. Make sure you don't turn it on permanently. This is understandable if there is a crescent icon in the device’s status bar.

Check your application settings

iOS has a very flexible notification system that allows you to customize each application the way you want. It can send Push notifications, it can show notifications only on the application icon, with banners at the top of the screen, it can show or not show notifications on closed screen. In short, there are many options, all of them can be viewed in “Settings” > “Notifications”. If, when you first launched the application, you accidentally blocked it from sending notifications, you can always change this setting in this menu.

Check the mute button

Absurd, but, as practice shows, extremely helpful advice. Small switch on the side iPhone panels does not affect the operation of Push notifications in any way, but disables system sounds notifications. So, if you accidentally switch it, you may not hear important notifications.

An important safety factor is the speed of response to events. A message about an event or incident that arrives 10 minutes late or does not arrive at all, in most cases, makes all investments in video surveillance, security, access control systems, smart home. For those without our own security personnel, we always install systems controlled via a smartphone or tablet, which allow you to view video, control automation, open and close door locks and gates, taps and other devices. And you often hear that the application works poorly, does something, but does not deliver notifications. But it's not always the developer's fault. Often the reason is in the smartphone, or more precisely in its operating system. Let's fix Push notifications.

The delivery service is responsible for delivering messages to your phone. Push notifications from Google and the operating system, and then they pass the message to the application for which it was intended. On devices Apple Usually there are no problems, but on devices with Android based delivery of notifications is done in such a way that it costs application developers a lot of work to make messages arrive and arrive on time, and they do not always succeed. Actually, Android itself does not prevent message delivery; problems arise due to the fact that each manufacturer has a bunch of its own add-ons and “improvements” to the base operating system.
Let's figure it out.

What to do if messages are not delivered at all?

Here are some possible reasons:

  • The user has not registered any active Google account on the phone;
  • Outdated version Google Play Services . It is necessary to update it, this may require updating the entire smartphone system;
  • Notifications for the application are turned off (checkmark on the application page in the phone settings);
  • Application operation is limited in background(the setting is located in the “Data Usage” menu);

In order for your security system application, or for example from WhatsApp, Telegram, Skype, Vider, to receive a message, your phone must contact the server and check if there is a new message for it, pick it up if there is one, and transfer it to the desired application so that it will already display it. This means that the phone must always be connected to the Internet, even if it is in your pocket. All this consumes the phone’s battery, and many manufacturers, trying to extend the operating time of the smartphone on one charge, prohibit Push notifications, or make checking very rare.

So, the reasons for the delays Push messages you should look specifically for “energy saving systems” (for example, Stamina on Sony devices), “application optimization”, etc. and here every manufacturer of Android-based smartphones invents its own wheel, and often remakes it from update to update.

In this article we will try to collect descriptions on disabling these Push message energy consumption optimizations for different phones.

It is worth saying what exactly disabling Push notifications have a very weak impact on energy consumption compared to the consumption of LTE or a power-hungry application. Enabling or disabling Push message optimizations changes the battery life of a smartphone on a single charge by a maximum of a couple of percent.

Samsung Galaxy S6

An application that harms us Samsung Galaxy S6, called . This separate application, which can also be found in system settings.

In the Smart Manager application, you need to click OPTIONS, in the right top corner. "Setting up notifications." And turn on the "Performance degradation" switch. The name is very strange and confusing, given the fact that it degrades performance in the off position. To receive Push notifications, the switch position must be as in the picture. The “Energy Saving” switch does not produce much effect, but you can also turn it on.

On ASUS devices


  • On device ASUS ZenFone 2 applications may not launch after rebooting the device or unloading the application from random access memory devices. To resolve this issue, allow automatic start for the application in the Startup Manager settings.

On HUAWEI devices

There may be the following problems and ways to solve them:

  • If power saving mode is enabled, pop-up windows may not appear. To resolve this issue, add the application to the list of Protected Applications in Battery Manager.
  • The application can be unloaded from the device's RAM using the operating system. To resolve this issue, pin the application to your device's RAM using Application Manager and add it to the list of Protected Applications in Battery Manager.

On Meizu devices

There may be the following problems and ways to solve them:

On Lenovo devices

There may be the following problems and ways to solve them:

On Samsung devices

There may be the following problems and ways to solve them:

  • The application may not launch after rebooting the device. To resolve this issue, enable automatic restart for it. For example, use Smart app Manager. Go to Smart Manager > RAM > Autoload App. and turn the switch on.

On XIAOMI MIUI devices

There may be the following problems and ways to solve them:

On ZTE devices

There may be the following problems and ways to solve them:

How to fix an application in the device’s RAM

Open Task Manager. For example, press and hold the middle button until a list of all running applications.
Find the application.
Click the Lock icon next to the app name.
The Lock icon indicates that the application is pinned to RAM.

IN last years Chinese smartphones have become very popular in Russia Xiaomi company, characteristic feature which is the proprietary MIUI interface. It has particularly deep system settings that are not available to users standard versions android.

However, despite significant advantages, many complain that in xiaomi redmi note 3 notifications are not received - what is causing this and how to fix the problem is described below.

Why don't I receive notifications in MIUI?

Although MIUI seems simple, user-friendly interface, but it is fundamentally different from regular Android. MIUI developers have improved the autonomy of smartphones due to some restrictions for custom applications(whatsapp, viber, vk, etc.). For example, bans on background processes, network connections and geolocation significantly reduce the load on CPU, thereby reducing battery consumption. Time battery life is significantly extended.

However, this created an annoying drawback. Users noticed that in xiaomi smartphones Sometimes notifications from your favorite programs do not arrive. Moreover, there are no notifications, even if the application was launched manually. And if the screen goes dark, you can completely forget that social networks and other services should send important notifications.

Therefore, many are literally tormented by the question, why is everything so complicated and how to enable notifications in MIUI? For their sake, users are easily willing to sacrifice autonomy in order not to lose the necessary alerts. To solve this problem, it is necessary to carry out a comprehensive reconfiguration of MIUI, because... Unfortunately, there is no magic “turn on notifications” button.

Background mode (power saving)

One of the points deep customization, which we still need to try to find. Let's take the example of our employee's smartphone, whose redmi note 3 pro no longer receives notifications. The menu name may differ depending on the MIUI build, so trust your intuition and look for something similar in the settings: Advanced, Performance and battery, Energy consumption by applications. There will be several power saving modes, of which “Standard” is active by default. It is he who blocks access to network connections and geolocation. Naturally, in such a remote offline environment, applications on xiaomi redmi cannot show any notifications at all. It is curious that in this mode, MIUI independently determines which background processes to block, so it is difficult to predict when certain notifications will arrive.

xiaomi redmi 3s power saving modes

If you found these settings, then you are also faced with the problem of lack of alerts in the “Standard” power saving mode. On at this stage There are 2 options.

  1. You can simply turn off power saving. Then MIUI should start working like regular Android, when the system kernel independently regulates all background processes, access rights, priorities, etc. Theoretically, all applications should have full access To background activity, networks, etc.
  2. Experienced users may do differently. Install maximum level energy saving ("Enhanced"), and then selectively unlock only important programs. This setup takes literally three minutes, but you can be sure that the smartphone’s resources will be allocated only for truly needed by the user processes. By the way, then you can also limit the background activity of system Xiaomi applications, which are unlikely to be in great demand by domestic users.

Setting up notification types

Setting up background app activity was just the beginning of recovery normal operation notifications. Few people know, but the MIUI interface also allows you to control the types of notifications from applications.

Let's explain with an example Facebook Messenger. The program can show notifications about messages in the curtain or change the indicator with a number on its icon unread messages. However, a floating round window on the desktop is much more convenient, because... Sometimes you cannot open the corresponding message from the curtain. If your phone has one type of notification, but lacks another, then the problem lies in the limitation of these same types.

To fix this, you need to open “Notifications and calls” in settings, and then find “Application notifications”. Next there will be a list of applications that are allowed notifications. You can turn off unnecessary ones, and for necessary programs- configure notification types and priorities. This is where the “Pop-up notifications” of applications are activated, as well as the normal transition from the curtain.

Autostart applications

This is quite important because... Sometimes enabled autorun actually affects the correct operation of some applications. You can configure automatic launch of programs during device startup through the “Permissions” menu, “Auto Start” in the “Security” section.

Let's go in and then install required parameters. It is advisable to set autorun for everyone important applications(social networks, instant messengers, etc.).

Pinning applications to RAM

This is a peculiar feature of the MIUI interface. Beginner users will not immediately recognize it. The point is that you can select applications that will always be in RAM, even if you “close everything” through the running applications menu. This is very useful feature to consolidate messengers, social networks (VKontakte) and dialers into memory. Thanks to this, pinned applications open almost instantly, the MIUI interface will force them to work, protecting them from unexpected closure. After rebooting the smartphone, all “pins” still work.

To do this in the menu running programs you need to “swipe” the shortcut down desired application(that is, where notifications are failing) and click on the lock. A padlock should appear on the shortcut, which means that the application is locked in RAM. To unpin, simply swipe the shortcut up.

Optimizing RAM and WiFi

In addition, in the “Energy Saving” section of the battery settings menu, there may be an option to periodically clean the RAM. This function removes from RAM Redmi Note unnecessary applications, which speeds up the operation of the device and reduces battery consumption, however, it is advisable to disable it if the situation with notifications is unstable.

IN WiFi settings It is also advisable to disable optimization, since when the screen is locked or turned off, the MIUI interface may simultaneously disconnect from wireless networks, again to save battery, but to the detriment of user convenience.

We hope these tips will help you overcome the notification problem. Write in the comments what exactly helped you cope with this problem.

26.05.2016

Every business and application company has its own lists of favorite clients and projects. We love our customers, especially those who, in addition to the finished product at the end, want to independently understand the technologies and rise to the level of a specialist. Any methods are used, but “question torture” is especially popular (any tester rests).

Technical portrait of the application being developed

We were creating a mobile application for a clothing store, whose architecture was built on a basic Activity (fragments are used to display information). The Retrofit library was used to download data from the server, and the built-in dependent library was used to store it. SQLite database. Loaders were selected to execute requests to the server and to fetch from the database.

To make the application interactive and allow you to exchange messages, we enabled push notifications. IN in this case VK and Facebook SDK are used to implement authorization/registration through social media and it looks like this: when a user sends a message, he sends a request with this message to our server. It generates a request with a message and data about the user to whom the message was addressed, and sends all information to Google server. It generates a push notification from this request and sends it to the user’s device. Our application receives this push, parses (processes) it and displays it in the chat - communication is realized.

There is a problem: when does the application start running in the background or why do push notifications only arrive after launch?

A client came to us with this question, because through experience he was faced with the following dilemma: when launched from a second device, the application works well, but how does “autoload” work then?

Let's talk. The application starts working in the background immediately after installation, and subscription to push notifications is carried out after registration in the application.

If the user does not register in it, then push notifications will not work for him.

There are other explanations to consider:

  1. Push notifications work through the GCM service ( Google Cloud Messaging), so if you don't have Google on your device Play Services, their work is unstable or the manufacturer has made improvements to their work, then push notifications will not work completely or there will be interruptions in their work. If Google Play services are not available on your phone, you won’t even be able to register for push notifications. Of course, this can also be done “forcibly”: if, after registration, the subscription to push notifications on the server is unsuccessful, then you need to continue trying each time you log into the application until the result is successful. The reason for this situation may be problems with the operation of Google Play services - in this case, an attempt to subscribe may end in nothing.
  2. The reason for incorrect functioning lies in the imperfect work environment. We recommend to our clients for testing, and call the ideal environment, the use of phones Google Nexus(they run “pure” Android without any changes, and the OS and services work on it ideally), stable work servers and internet connections. Under such conditions, requests will be issued correctly, without errors and as quickly as possible. In this case, the application will quickly load new data, display it, and there will be no problems with incorrect display information. In other phones (with modified operating systemChinese brands, Samsung, HTC, etc.) you can expect not only unstable work server, but also limited opportunities application being developed (due to system removal many methods-functions) - yes, push notifications may not be provided at all.
  3. Don't forget the main thing - push notifications only come if there is a stable Internet connection. If this is not the case, then the message will come as soon as the connection is restored.

Summary

  • An ideal environment (flawless Internet, “clean” platform) is ideal, so warn clients about all possible errors and limitations of the application functionality.
  • Don't be afraid of clients' questions - they will carefully look for flaws in your work and find them! Thank you and fix the bugs promptly.
  • First of all, create an application for users, focus on them technical capabilities and don't create unnecessary things.
December 28, 2015 at 12:25 pm

Push notifications in Android. Rakes, crutches and bicycles

  • Mobile application development,
  • Android development

I was prompted to write this article by a task that was assigned to me in one of my work projects: to implement Push notifications in an application. It seemed that everything was simple: you study the documentation, examples and move forward. In addition, I already had experience working with notifications. But it was not there…

The service, within which the Android application is implemented, has quite strict requirements for the operation of Push notifications. It is necessary to notify the user of some action within 30-60 seconds. If the notification is successful, a request is sent from the user's device to the server with the appropriate status. From the documentation we know that the GCM (Google Cloud Messaging) service does not guarantee delivery of PUSH notifications to devices, therefore, as a backdoor option, if these time frames are violated, our service notifies the user with via SMS messages. Because the SMS cost messages are significantly higher than PUSH notifications, it is necessary to reduce the flow as much as possible SMS messages to client devices.

After studying the documentation and installing push notifications, we sent the first build of the application to test to several clients and began to wait. The results were approximately as follows:

  • with active Wifi connection everything works perfectly: notifications are delivered, clients are happy.
  • with active mobile internet The fun has begun.
Some clients wrote that they experienced delays in the delivery of push notifications, or received both PUSH and SMS at the same time, which is quite impractical. Others wrote that they received no notifications at all, but only SMS. For others, like our test devices, everything was ok. Collecting as much as possible from dissatisfied customers possible information, began to understand the problem and came up with the following list of restrictions (this list later resulted in a full-fledged FAQ):
  • Enabled Energy Saving mode (for example, Stamina on Sony devices) affects the operation of Push notifications;
  • The user must have at least 1 active Google account on the device;
  • you need to make sure that your device has current version applications “ Google Services Play”;
  • check whether notifications for the application are disabled (check the box on the application page in the phone settings);
  • check whether the background mode for the application is limited (the setting is located in the “Data Usage” menu);
  • The GCM documentation states that notifications are sent only to certain ports, so the settings of the router, firewall and antivirus are also worth taking into account.
Having sent this reminder to all clients, we again began to wait for the results. And they turned out to be “not very good” again. They began to dig further.

At this stage, the message written by the guys from Mail.ru helped a lot. It describes in great detail the intricacies of implementing GCM on the client side, as well as the points due to which Push notifications refuse to work in mobile networks. Ultimately, the decision was made to keep my connection to the server in conjunction with GCM.

Before making a decision, it is worth highlighting a few very important points, which allow you to narrow down the range of potentially “non-working” devices:

  • the problem occurs only when connected to the mobile Internet;
  • According to customers, the problem occurs on Android version 4 and higher.
And so, let's move on to implementation.

An experienced Android developer will immediately say that there are at least 2 solutions to the problem: use Service or AlarmManager. We tried both options. Let's consider the first of them.

In order to create a system-indestructible service that will constantly hang in the background and perform our task, we used the method:

StartForeground(int notificationID, Notification notification);
Where

  • notificationId - some unique identificator notifications that will be displayed in the status bar and in the sliding curtain;
  • notification - the notification itself.
In this case prerequisite is to display a notification in the status bar. This approach ensures that the service will be given higher priority (since it interacts with the UI part of the system) when there is a lack of memory on the device and the system will be one of the last to unload it. We don’t need this notification, so we used the following trick: it’s enough to launch the second service simultaneously with the first one and for both services as notificationID use the same value. Then kill the second service. Wherein the notification will disappear from the status bar, but the functionality and priority capabilities of the first service will remain.

Having realized this approach, we sent the assembly for testing. Based on the results, it turned out that the system was still unloading the service, and from the logs we saw how significant time gaps occurred when requesting data in the background from our server. Therefore, we started implementing the second option - AlarmManager.

AlarmManager is a class that provides work with, roughly speaking, an “alarm clock”. It allows us to specify the time after which the system will send a broadcast notification, which will wake up our application and give it the opportunity to perform the necessary actions. There are some limitations to how this method works and they need to be addressed:

  • data about “alarm clocks” will be erased after rebooting the device;
  • Alarm data will be erased after updating the application.
The first rake we stepped on was the method

SetRepeating()
which allows you to set an “alarm clock” that repeats at a certain interval. Screwing it on this method, they started testing, and the tests showed the opposite - the “alarm clock” did not repeat. We began to figure out what was going on and looked at the documentation. And it was there that they found the answer to the question - starting from API lvl 19 (Kitkat), absolutely all “alarm clocks” in the system became one-time ones. Conclusion - always read the documentation.

This rake was not a reason for frustration, because the solution to the problem is quite simple - launch a one-time “alarm clock” and reset it after it goes off. When implementing this approach, we came across the following rake - it turned out that for different levels The API needs to set alarms differently, but nothing was said in the documentation. But this problem I solved it quite simply - at random and by googling. Below is a code example that allows you to set alarms correctly:

Private static void setUpAlarm(final Context context, final Intent intent, final int timeInterval) ( final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); final PendingIntent pi = PendingIntent.getBroadcast(context, timeInterval, intent, 0); am.cancel(pi); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) ( final AlarmManager.AlarmClockInfo alarmClockInfo = new AlarmManager.AlarmClockInfo(System.currentTimeMillis() + timeInterval, pi); am.setAlarmClock(alarmClockInfo, pi); ) else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) am.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + timeInterval, pi); else am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + timeInterval, pi);
I want to draw your attention to the flag AlarmManager.RTC_WAKEUP- it is with the help of it that the system will allow our application to “wake up” when the screen is inactive, when the device is in a locked state.

This approach with “alarm clocks” gave us desired result- the application in the background correctly polls the server for new data. We are currently finalizing the algorithm. On this moment We are implementing and testing the following optimization, which will allow us to narrow the range of devices and thereby reduce the load on the server:

  • the message sent by GCM to the device contains some unique ID;
  • having received the data GET request in the background we check whether an entry with the same ID already exists on the device;
  • if there is no such data locally on the device, we remember this ID and the time it was received T1;
  • we wait for PUSH with the same ID, upon receipt we remember the time T2 and check the difference between T2 and T1;
  • if the difference is more than some temporary criterion (value), then the device has a problem with delivery of notifications and for correct operation the service must constantly request data in the background from the server (I advise you to choose the criterion based on the problem being solved. In our case, the criterion was chosen equal to 5 minutes);
  • this difference should be calculated several times, for example 5-10 times, only after that we can conclude that the device really has a problem with receiving Push notifications (this way, the situation of a banal connection disconnection, timeout, etc. is eliminated);
  • needs to be driven away this algorithm periodically (for example, once a week, or after updating the OS on the device).
All the best. And fewer such crutches.

P.S.
Helped a lot during the testing process