gcm push notifications, progressive webapp - android

I followed the google documents to create a progressive webapp and I've just implemented push notifications, however whenever I close the app I don't get any notifications.
Other apps like whatsapp seem to be able to send those notifications is there a difference between native notifications and gcm push notifications from a progressive webapp?

There absolutely no difference between the two, the rendering part is the same, it just that native ones are the notifications that comes from a apk generated app and the other one is rendered using google chrome or any web browser that support the functionality.
Beside the service worker with the help of manifest.json file will use the GCM ( Google Cloud Messaging) to send notifications to end users.
I worked and implemented such functionalities before, and I got my notification directly to the browser and my android phone as well, therefore I created a Github repo with nice documentation that simulate just that using Nodejs and simple web interface, please feel free to check I guess it holds what you seek :
Link : https://github.com/houssem-yahiaoui/webpush-notification

Related

Make Web push notification work using webview in a native android app?

I have a website which is responsive and push notification feature enabled. In my native android app, if i load my website in a WebView, then the pop up which usually comes in chrome/firefox to ask if user wants to allow push notification or not, doesn't shows up in WebView. And obviously the WebView won't support the same web push notification for the app. I know how to implement GCM or FCM in app to enable mobile push, but i wanted to know if it possible just to club the web push notification with android webview so that it would work in my app as it is working in chrome/firefox etc.
What I tried: After digging deeper into this, I finally concluded that as android WebView doesn't support Push Api (with the help of caniuse.com), clubbing of web push with mobile push using WebView is not possible as of now. Am I right? Or is there any app which already does this? Is it possible somehow?
Ow, of course this is possible!
I easily implemented push web notifications from one signal in my webview App using crosswalk.
Uses crosswalk, extends Main activity to XWalkactivity
Put this on on create:
OneSignal.startInit(this)
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
.unsubscribeWhenNotificationsAreDisabled(true)
.init();
Yeah, you will have web push notifications working!!!
As I'm aware, it's not possible using only WebView .
The solution that worked for me was to find whether the website you want to display in the WebView uses WebSockets. If yes, the notification will probably be available in the according WebSocket communication. The workflow is following:
Determine WebSocket on the website. You can use Firefox "Inspect Code" and in "Network" tab filter out only WebSocket entries.
You can test connection to ws via various tools. Simple-WebSocket-Client for Firefox or command line tool. Simply provide URI to your WebSocket (ws://domain.example/ws).
Implement WebSocket client in your application. There's been different posts on how to do that. I've used this lib to make it nice and clean.
Now you are receiving messages from server, such as notifications.
Parse them and do whatever you want.

Can I Use Application Web Services Which is Already Made for Android in iOS especially in push notification

Is their any difference between web services for android and iOS ?? especially if i am implementing push notification using google cloud messaging
Thank you in advance
Web services
There shouldn't be any major differences between web services for Android and iOS. Especially when it comes to exchanging JSON with object representations. At the end, it's all the same, parsing and mapping. Sometimes you might want to return some special, platform specific information. In this case, the mobile clients need a way to tell your backend which OS they're running.
Push notifications
Push notifications is a different story. On Android you have Google Cloud Messaging and on iOS Apple Push Notification Service. Your back end has to know which notification service to use.
There are many ways to solve this problem.
One way is to set a custom HTTP header that would contain information about the OS the mobile client runs. Another is to have a parameter that is sent with each request.

Mobile Push Notification using Web App

1- I want to write a simple web app (not native) used to send my clients news via push notification on ios, android, etc.
I found pusher.com, but the demo is not working.
It could be great if I can link it to my rss url, so they can get notified whenever a new record is added.
2- I want to add shortcut of my app on client devices.
Thanks
You can use GCM for android, and APNS for iOS, and there are many tutorials of these. Especially, iOS very strict rule for push notification, or your app will be rejected.

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.

Push Notifications in Android using Google App Engine

I am currently developing an app where users create posts that are stored on a server. When another user shows interest in a post by clicking a button, I want to notify the author of the post using push notifications. I have already set up the data storage using cloud endpoints with Google App Engine. Is there anyway I can use these endpoints to implement push notifications? If not is there another easy way to implement push notifications given my current setup? I have already read about Google Cloud Messaging on the developers page but was somewhat confused. I have kept track of the registration id's but I don't really know where to go from there. Thanks in advance.
You can use the HTTP interface to the GCM servers as described in this
Android developers page.
The easiest way to do it is by downloading the Google Cloud Messaging for Android Library using the Android SDK Manager, which will give you a jar that handles all the complexity of setting up the requests and responses to GCM.
Towards the bottom of that page, there is a sample Java application for push notifications on App Engine which you can use to get familiar with sending push notifications and then adapt to your needs.

Categories

Resources