Push Notifications for different platforms and devices in China - android

I read a lot of articles about how to implement Push Notifications with Cordova (and Ionic 2) and I'm not sure how to implement that in China when not using Google's push server.
I think using https://github.com/phonegap/phonegap-plugin-push is a good idea. But all the Howtos are focussing on creating an account in Google's FCM which is not really helpful in China. I doubt Chinese phones use Google to poll for notifications. Which leads to my next question.
I was assuming that there exists only one central push service for all platforms (Android, iOS and Windows) and vendors for the following reasons:
One platform is only polling from one fixed push server to save battery life.
If an app (server side) is sending a push notification, it does not know anything about the receiver's device, so it can only count on a centralized service delivering the message to the device regardless of platform or vendor.
But do Apple, Google and Microsoft all use the same push service? I doubt it, and that's what makes me confused. Also, if I'm in China, as Google's services are unstable here, the Android phones distributed in China are not using Google and even not install Google Play Store.
When I install a Chinese app (hosted in China) on a German phone (Android) I still get all notifications for that app even if I'm obviously polling from Google's push server. That means, the notification messages of the Chinese app is somehow delivered to Google.
The only explanation for that is that the different push services are working together. Is that the case? If so, than does it make a difference where I create an account (Google FCM: https://medium.com/#ankushaggarwal/gcm-setup-for-android-push-notifications-656cfdd8adbd#.rr2lfivfh), it is still usable on different push servers? Also, when I send a notification, could I use any server all over the world?
How can I find out which push server my phone is connected with (Android)?
A lot of confusing here, I really appreciate if someone could bring light to that topic :-)

The reason GCM / FCM does not work in China is simply because the Great Firewall of China blocks connectivity to all the various Google services, FCM included.
Also, most, if not all, China-sold phones do not come with Google Play Services, a requirement for FCM to work.
Even if you were to take a German phone, as you mentioned, into China, it would not receive notifications albeit having Google Play Services, due to the firewall.
But there are alternative push notification gateways you could use instead, which are far more reliable and do not depend on Google Play Services. One of those is Pushy.
Pushy (https://pushy.me/) offers a highly-reliable push notification gateway for Android apps that works independently from FCM, using its own background MQTT connection. It also offers iOS support so you can push all of your users via a single API for cross-platform support.
Full disclosure: I founded Pushy.

With Cordova, you can use the plugin cordova-plugin-xiaomi-push done with the Xiaomi Android SDK. I have tested and it works well with all the phones when the application is running. And even when the app is closed with Xiaomi phones :)
The advantage to use Xiaomi is that their developer website is in English and their server's APIs are simple.
There are also 2 plugins for Huawei and Oppo, which work well with the respective brand phones, even if the app is closed. But the API side is more complicated than with Xiaomi. To cover all the supplier with notifications when app is closed, it seems necessary to build one version per manufacturer/stores which include the required plugin (That is possible using a bash script) + build a push server that would send the notification to the right provider.

Google FCM notification not works in china country. You have to use some different push notification provider like Pushy.
For China Country, I used pushy service. You can go through this link if you wanna interested to use pushy service. Please check this link.This will help you

Related

How to send notification to phone without play store (like huawei)

How to send notification to phone without play store installed (like Huawei). I know that Huawei use appGallery but how to send notification to those phones ?
Huawei does offer such a service. It's called HUAWEI Push Kit and is part of HUAWEI mobile services (HMS).
Documentation can be found here: https://developer.huawei.com/consumer/en/codelab/HMSPushKit/index.html#0
Also, I currently do not know about any service which abstracts from the push-backend. Firebase would be a candidate, but currently they only support APNS (Apple) and Google Push. So its up to the developer to support every individual push system.
You can use something like xmpp, websockets, gRPC etc. but your app will need to be in the foreground to get messages from your server (or have a foreground service running). To be able to get push messages like you would from firebase you would need something that has system level permission and is excluded from Doze mode to be able to get push messages in the background. Somthing like that would have to come from the manufacturer.

create my own push notification service without fcm , pusher ,

I want to create a notification system provider that is not based on Google services or similar. In fact, I want to get information about its overall architecture and needed Android sdk functionality.
The most weird point for me is to understand how to send a notification to an Android device.
I mean, how can I identify the Android device on which my application is installed from millions and millions of other Android devices on the Internet?
And how do I send information to him?
Should I use sockets for this or similar stuff?
simple answer: YOU CAN NOT
before everything else i should correct your question, pusher and FCM are not in the same group at all! you can build somthing like pusher or oneSignal or etc but you can not build something like FCM/APNS
you should understand three simple yet important sentences below:
when you want to pull anything from place_1(e.g. api) to place_2(e.g. browser_client) you most have an identifier of the place_1_resource (which commonly is the uniform-resource-locator of api)
when you want to push anything from place_1(e.g. notification_central_server) to place_2(cellphone_client) you most have an identifier of the place_2_resource
you must know the differences between a real server push with server-push-like technologies like long-pulling or ... and you should be aware that what is intended in this concept is a real server push not any kind of pulling with a push jacket!
if you don't have any identifier for a cellphone which you want to send it a notification, your server dont know where to send that notification so we need a resource_identifier_like for cellphones which is actually a device_token_like and you have just one approach to get this device_token_like and that is the FCM/APNS
FCM is like a dns server containing all identifiers of every android device that google supports (almost every android device) and APNS is just the same but for apple devices
note1: even if your app can obtain it's corresponding device device_token_like it can not be used for push notification if its not registered on FCM/APNS
so when you get that device_token_like identifier of your desired clinet_device now you can use different approaches for sending sth to that clinet_device. there are several approaches like SSE, Webpush, HTTP_server_push, Pushlet and etc but none of these approaches supported by mother_companies of these devices, the only approach that is completely supported and standard is the same approach that FCM/APNS official websites suggests
for example an iranian Incorporation named najva uses webpush to send notifications because of USA sanctions but webPush method works good on browsers and android devices but they didn't even apear on an apple devices
finally i should say that i admire your curiosity to less using anything from a benefit_based Inc. like FCM/APNS in your developing but i strongly recommend these articles and books for you cause i think you didn't learn enough:
wikipedia of push technology
story of some guy who tries to make his own push notification service
Push Technology A Complete Guide - 2020 Edition
Data Push Apps with HTML5 SSE
Short, direct answer
You can't (At least till you create your own ROM)
TL;DR, Reason why?
Before you build your own push notification server, you first need to know how it works internally in android.
Whenever you/your server sends a push notification message to the android client, the SDK processes it and shows you the notification. But when your app is not running (or being killed), your app cannot respond to it since it was not running. In such a case, your notification message is sent to a system service which is known as Google play service. For this even to work, you will first need to bind your app with Google play service and that is what FCM does. FCM SDK registers your app to the operating system service on the first initialization. That FCM service is opened to a port which listened to the incoming message from the server and when it receives the message, it publishes a notification on behalf of your app with a PendingIntent containing the data. Then the PendingIntent is delivered to your app when the user clicks it and then finally your app process the data (or the push message)
So basically, for your server to communicate with the client, It first needs to communicate with the FCM service and for that, FCM gives you a token which identifies the application to register with the internal Google play service.
Simplified furthermore, the workflow is as follows:-
Server send push message ---> FCM ---> Google play service,
If your app is running, it is directly handled by the client SDK So, Google play service --> Your app
If not, then it is delivered by the service itself using PendingIntent So, Google play service --> PendingIntent --->| Publish notification
Totally impossible, Workaround?
There is nothing like impossible because an absolute impossibility doesn't exist. Saying impossible generally means near to impossible. (This is similar to math where also we say tends to infinity because no one has achieved it yet).
To make it work, you need to somehow bind your app to the Google play service and you can't because Google hasn't exposed any direct API to do that. The only possible way is using the FCM ;-) (Bad luck again). So the only possible way is to build your own custom ROM with a custom push service that acts as a client for your Push server and a Server for your Push client (which is your app).
Since the above option tends to impossibility, you have to choose a workaround.
The best among the worst workarounds are:-
To make a malicious SDK.
Malicious because it needs to keep the app running in the background with a service that is connected to a WebSocket endpoint of your server. (Harder in new android versions).
Make use of a database where your push notification is saved and your app checks it periodically using AlarmManager.
Hope you have got the point.

online notification in android

I've built an Android application by android studio.
I want to be associated with users online and notify changes and news.even when my application is closed.
This is what is on my mind,I have web server, i want create a internet connection listener and when connection is available,application or a part of it connect with the server and get new information and notify the user with a notification.even when my application is closed.
How can I implement and enforce it?
Try "Google Cloud Messaging."
Per their Developer Console Help page: "Google Cloud Messaging (GCM) is a free service that helps developers send messages across multiple platforms: Android, iOS, and Chrome. For example, a server can send messages directly to single devices, groups of devices, or devices subscribed to topics. Also, the application on a device can send messages directly to a server and to devices belonging to the same group."
Use the Google Cloud Messaging service alongside the Google Plugin for Eclipse. Google Cloud Platform explains as: "When targeting Android devices, it is easy to get started by using Google Plugin for Eclipse (GPE). GPE allows you to generate an App Engine Connected Android Project that provides the basic logic needed for sending push notifications using Google Cloud Messaging for Android from a mobile backend running on Google App Engine."
This could send messages for you without having to do the work on your own server. If this answer helped you, please consider up-voting or accepting it as the answer. Thanks, and best of luck on your project!
No,These systems are always some limitations and managed with others.I do not need to communicate with iOS or chrome ,I need to design a system that's all for me.Experience has shown me great services, such as Google services and any other company affected by political issues.for example i live in iran right now.
All production-oriented and knowledge-based services for this country is banned.
due to this problems i prefer to have my own messaging and notification system.

Correct way to send push notifications

I want to send a notification from some server to android device. The most obvious(and power-hungry) way is to keep searching some database for any new messages using a service/broadcast receiver.
I am sure there are other ways to get this job done. I took a look at GCM(google cloud messaging) , and it seems that google always keeps some TCP/IP connection active. This essentially means that using GCM will use less power.
However, I have a few questions regarding GCM.
Does a user NEED to have google services, and a registered play id ?
If a user side-loads an apk, will he still be able to receive notifications ?
I would like to know if there are alternatives to GCM
What about devices running forked android versions, like nokia X , kindle etc? How are push notifications sent to those devices ?
Does a user NEED to have google services, and a registered play id ?
Yes, it is necessary to use Google Play Services in your development. However users do not need to have a Google account or the Google Play Services Installed.
If a user side-loads an apk, will he still be able to receive notifications ?
Yes.
The steps that must be followed to send a notification to a device are:
Developer creates application in Google Developer Console
User installs application
Application gets a NotificationID and sends it to your database
You store the NotificationID at your servers with any other information related (your username, device info, etc.)
Whenever you want to send a Notification you connect to GCM sending one or more NotificationID and the notification content.
The users related to the NotificationID will receive in your Application the notification content.
Do any action you need.
Have a look here.
IMHO there is not any real alternative to GCM in Android (based on efficiency and simplicity). You may look for 3rd party services that will help you in the implementation and add value (marketing, business intelligence). As an example of this take a look to UrbanShip.
If you want to implement your own solution you should have a look to WebSockets. This will mantain an active communication between your server and the device. Those sockets are thought for real time communication between your server and the mobile.
Two issues:
How is the application affecting the battery depends on your implementation and the application use-case (how frecuent are you sending information, how long is the connection stablished).
I am not aware of any native implementation of this in Android but there are a few Libraries coming from open source projects. Google it.

Right way to establish push notifications for Android/iOS

Assuming my application is based on HTML5/Jquery mobile (Cross platform web app),
How is it possible to create push notifications for Android/iOS ?
Also, does it include developing different "notifications engine" for
each device? (in other words: Do I need to implement two different background processes for each type of device?)
I'd be really glad to get a full answer/references to my conflict.
I have searched for the forum's previous answers but it seems like the threads are quite old so i preferred opening my own question.
GCM is the Google Cloud Messaging Service for Android, while APNS is the push notification service for iOS, both of them are very similar.
If you're already using html5 and jQuery, I would suggest you to use Phonegap which is a framework that allows you to create mobile apps using only html5 css3 javascript(jQuery) it was very useful for me and they've a push notifications plugin which works for Android and iOS.
Be sure to check Phonegap and Phonegap Build (which is a very interesting service)
Regards
1)
Apple has Apple Push Notification Service (APNS) to push out alerts.
More details at
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html.
Google offers a comparable Google Cloud Messaging Service (GCM).
Details at http://developer.android.com/google/gcm/index.html. UPDATE: GCM does support iOS as a client, so can be used for both Android and iOS, with some work. (Technically, it will be an APNS when it reaches the iOS device.)
2) Not sure I understand what you mean by "background processes", If you are referring to backend service/originator of notifications,then the service needs to be able to communicate i with both the Apple APNS or Google CDM using the interfaces supported by these services and send out alerts in appropriate format. If you are looking for a third party service for sending out push notifications, you can checkout UrbanAirship or Parse which can send notifications to either platform.

Categories

Resources