
Enough major update correcting errors in the android client, improving the security of getting the user ID, sending one push to the user group in the channel, as well as the API for working with user lists.
Today in the heading:
- We use PushAll and Telegram when developing in a team
- Icons gobbled up my traffic - help!
- Why I see only their piece?
- Emoji killer!
- How to combine a thousand iterations of sending notifications to one (multicast)
We steal personal dan We receive the list of the users subscribed to the channel- Subscribe to push notifications to your friends (vulnerability)
- We do not wait for sending all notifications, we perform everything in the background.
I will describe in the style of the problem and its solutions
Notification icons cropped
They addressed me with the problem that on Android 4. * the icons are cropped. More specifically, on the old versions there was no automatic fitting of icons.
')
It was solved simply:if(icon != null){ Resources res = getApplicationContext().getResources(); int height = (int) res.getDimension(android.R.dimen.notification_large_icon_height); int width = (int) res.getDimension(android.R.dimen.notification_large_icon_width); int realwidth=icon.getWidth(); int realheight=icon.getHeight(); if(realwidth>realheight){ height=height * realheight / realwidth; }else{ width=width * realwidth / realheight; } icon=Bitmap.createScaledBitmap(icon, width, height, true); }
Above is the algorithm for adaptive changing the icon for the device. While filtering is used, in parallel with this, we also improved the quality of displaying icons on newer versions of Android.
The application downloaded 100 MB of traffic per month in the form of icons
I have already noticed this problem, and I considered it to be very serious. You can also include such problems in it:
- Long notice delivery when downloading an image via an unstable connection
- No icon with a bad connection
- The lack of icons in power saving mode.
I want to tell about the last in more detail. The fact is that Android, in new versions, in power saving mode, disables the background transfer of all non-system applications. This leads to the fact that the notification comes, but we can not load the icon.
Solution: create a caching algorithm.At first, I struggled for a long time to ensure that the algorithm used standard HTTP cache facilities.
connection.setUseCaches(true);
I even found a solution to override the caching algorithm, since There was no standard one, and it seemed to work, with one exception - if there is no network - the icon will not load anyway. That is, Android blocked exactly all HTTP requests, even if caching is being checked.
Then I wrote my method, which checks for the presence of md5-file name in the cache folder. And if it is, it uses it. The network is not used at all. This is a fairly hard caching, that is, to change the image, you should always change its name, otherwise the old one will be loaded.
public Bitmap getBitmapFromURL(String strURL) { Bitmap myBitmap; BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.RGB_565; File file = new File(cacheDir, md5(strURL)); FileInputStream finput=null; if (file.exists()) { try { finput = new FileInputStream(file); myBitmap=BitmapFactory.decodeStream(finput, null, options); finput.close(); return myBitmap; } catch (IOException e){ return BitmapFactory.decodeResource( getResources(), R.drawable.gcm_cloud, options); } } try { URL url = new URL(strURL); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
Above, I described the final algorithm for generating bitmap from a link with cache checking and the MD5 function I found on the network. I think the code is simple and there is no need for comments.
Also, the algorithm uses a picture size limit of 512 kilobytes.

Bottom line: when subscribing to 20 channels, the user does not load more than 1-5 megabytes per day. Also, notifications come much faster, and icons are displayed even if there is no network, of course, provided that the channel does not use new icons every time.
Anyone could introduce a callback link to their website and “tie” their devices to someone else's accounts.
It is strange that we did not think of this earlier, but this is so. We have added new methods of protection.
The new address is: ADDRESS? Pushalluserid = ID & time = UNIXTIME & sign = SIGNATURE.
That is, the “pushalluserid” parameter with the user ID and parameters for verification will be passed to you in GET.
To verify the signature, use md5 ($ key. $ Pushalluserid. $ Time. $ IpAddress).
Where ipAddress:
$ ipAddress = $ _SERVER ['REMOTE_ADDR'];
Where $ key is the key of your channel. Where $ time is UNIXTIME.
You can set the required verification level yourself, for example, after checking the time and IP, the key is considered valid for 1 minute. Also make sure that the time on your server is accurate. If desired, the link can be considered valid in general seconds 5.
It also remains to work backward compatibility. That is, after the introduction of this method of security, your current applications continue to work. But you need to implement the protection on your side as quickly as possible.
As a result, we have a check and security implemented without additional requests. The main thing is to admit your mistakes and correct them in time.
Why is the whole day already pushing the same post via RSS ?!

In general, something like this, it turned out even ominously little.
What happened? Yes that's what

Tinkoff put Emodzhi in post. It was the same with another channel. Since the server is utf8_unicode_ci, and it is three-byte, mysql chopped posts by emodzhi. The problem has 2 solutions, is to use utf8mb4 or cut out emoji.
The first takes time, applied the second crutch:
function removeEmoji($text) { $clean_text = "";
It was not possible to send notifications to a group of users, only one at a time.
This problem has been brewing for a long time. At the moment, one of the channels uses unicast to send to several people, its volumes are not so large, but the new partner will need to send more than 10 thousand notifications at a time, so multicast has become a priority.
Features such as:
- Filter - taken into account (in unicast not, which allows you to notify the user through the filter)
- You can select 1000 users at a time in an array. (Of course, such volumes should be sent via POST)
- You do not need to make an additional notification and send all the data, send lid (push ID in the log) and new shipments will be assigned to it, moreover, you have to do it, otherwise it will be difficult for you to track the statistics and work in the future with notification
Also below I will describe at the same time the opportunity to divert the task to the “background” mode. That is, you do not need to wait until the system sends all the data to Google, and will work with the telegram (which is very long). You simply give the request and get the ID of the push with which you work further.
$ch = curl_init()
The code above allows.
- 1. Perform tasks quickly, sending them to the background
- 2. Send several thousand notifications with the same ID in a loop
- 3. Use Keep-Alive for faster communication.
Background - available today.
Multicast is still in development and is being tested, will be available in a week.
How to get user lists?
Earlier, I described the showlist method. Now he has a parameter - subtype = users
When using this parameter, you get a list of all users, and if you add a uid = user ID, then you can select a separate one.
You get all the data as when viewing the list through the site.

Telegrams for groups, business and development
After adding the telegraph integration function, many people wrote to me with requests to work with groups.
Why do you need it?
- It turns out there are online stores that discuss orders in the general chat and coordinate actions. It is convenient for them when they notify the general chat from their store.
- There are development groups that want to receive in a general chat, commits, bugs, updates or pushies from their systems and then discuss it in a general chat.
You just need to add the
@PushAllGrBot bot to the general chat, write / getid and register the received ID in the channel settings.
At the same time, your subscribers will also be able to receive notifications to their devices in parallel with the telegram.
Results, what awaits us next?
We fixed a lot of bugs, made a lot of new features and optimizations. In a week, we are planning to release a native iOS version. We are actively integrating with new sites and services, as well as waiting in our directory a lot of volunteers who can integrate the system on their own.
New composite filters, rating systems and channel reviews and more will be available to users soon. Applications will be able to customize the sound of notifications and vibration.
Ask questions about new features, offer new features that you need.
Have a good day!