Sending push messages to all open chrome browsers via GCM - php

I am trying to develop a web site which will send push notifications to all users currently watching it. I found some tutorials on how to send pushes to myself using GCM for Chrome and they are working fine,
(https://github.com/gauntface/simple-push-demo)
but I cannot understand how to send pushes to every user who is currently on my site and allowed to receive them. As far as I understand I need to collect their browser IDs when they subscribe
navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
serviceWorkerRegistration.pushManager.subscribe({ userVisibleOnly: true })
.then(onPushSubscription)
but I cannot find how to get and store them (perhaps in MySQL DB with PHP code) and after that how to send a push to everyone (probably to iterate over all browsers IDs in my DB and send pushes to everyone separately with cURL requests). On my site I have code which uses ServiceWorkers and handles users subscription but everything is working for me only. Noone who is else on a site does not receive any notifications. Any help would be appreciated.

Related

sending fcm notification messages to multiple android devices by registration_ids parameter

I want to send notifications to multiple android devices(where same app is installed) by fcm from php server side by calling this url -
https://fcm.googleapis.com/fcm/send
I checked sending messages to device groups but my requirement is such that there will not be definite devices to which i will send messages because i am going to do it in a hourly cron job, and each time a cron job runs it will send notification messages to different different devices according to requirements. or can it be done in another way?
But i am thinking to use "registration_ids" parameter instead of "to" parameter, details of these fields here in the Downstream HTTP messages section. In this registration_ids field i will put all required device registration tokens in array. Now my question is after receiving message in android device can the message be parsed in the android app sdk codes?. i am in a bit of doubt as in this documentation there are no mentions of registration_ids parameter when sending messages to multiple android devices. Please assure me. And furthermore, will the message be sent when android app is in background?!. Please don't write one line, provide some examples if possible.
In the documentation for building requests to send to multiple devices you will find an example of passing multiple FCM tokens in a single call to the FCM API in the tokens parameter (in Node.js) or by using a HTTP batch request with multiple subrequests (in the REST API).
If you're having a hard time making this work, posting a question that shows what you tried increases the chances that someone can help making it work.
Yes, the message is sent regardless of whether the app is in the foreground, or in background. Whether the notification is actually shown depends on many more factors, many of which are outside of your control (such as the Android version, device maker/OEM, and the user settings).

Send HTML email without user interaction by calling PHP script from iOS Swift 3

I recently ran into the problem where I found out that Apple does not allow developers to send an email directly from code without user interaction. This causes some difficulties on my app as I need a code generated email which is in HTML format to be sent from my website server to myself, a third party and the user of the app. I have a few questions regarding this:
Is it acceptable to use a PHP script to send the emails for me by calling the script from code?
Will doing it this way have my app rejected from app store as I have read that bypassing user interaction in this regard will have the app rejected?
There are tons of apps on my iOS device that send emails without me having to interact except for pressing a "submit" button or similar. How are these apps doing it?
Basically, I also need the client to just press a button and 3 emails are sent in HTML format. The client is aware of an email being sent, but I need it in HTML format without the mail client showing up. I have the same app developed on Android and if I cannot have the same flow on Apple devices it kind of breaks look from android to ios. I know this is possible as I have apps on my phone that does it. My question is, are they using PHP scripts? If so, I can do that, but I want to be sure that my app will not be rejected from App Store.
You can use the API from your webserver for this. If you have for example an API path
/mail
You can send all the relevant information in as POST paramaters (e.g. "subject" : 'test mail') and from your webserver send the email with a mail function.
This is perfectly acceptable.
You can attach this webserver call to a UIButton to make it user-interactable:
#IBAction func mailToUser(sender: UIButton) {
// POST request to /mail with relevant information
}

Send Push notification to specific Users

I am trying to develop an android app that verifies a transaction initiated from a browser on a PC. I want the server application to push a notification of a new transaction to the app so the user can confirm to complete the transaction. The tricky bit is the transaction is specific to a particular person (I'm using this as an alternative to sending an SMS for example). Can anyone help on how to go about this? Is it possible to do this with C2DM or GCM?
Using Android GCM is advisable. The complete reference to GCM is available at
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
Step by step GCM development is given in there. It is really very helpful. Hope this is helpful to you.
The critical thing you need to keep in mind before making a decision is that when you are using GCM, you need to keep a track of the users by keeping their GCM_ID in your database. You can add a gcm_id column to your users table for this and whenever the user opens your app, the gcm_id should be updated in your database. The gcm_id of the user's phone can change, from the official docs:
Note that Google may periodically refresh the registration ID, so you should design your Android application with the understanding that the com.google.android.c2dm.intent.REGISTRATION intent may be called multiple times
GCM push notifications wont be able to reach your users mobile phone all the time,especially if his phone is not connected to internet or switched off.You are using this for transactions etc, so I assume that the notifications must not fail. You should keep a check in your web application to send an SMS or notify the user that this has failed. You should get a response from GCM to your server through which you can identify a failed case.

AS3/Air iOS and Android data sync data to/from multiple devices to remote DB

I am about to undertake the development of an app that requires sycning of data from the local device to an online DB...and back.
I am building something that will allow users to create events and invite users to those events. Users will also be able to chat and receive in app notifications. I would like to store the information in local storage that the user creates and push this information to an online DB when there is internet available. Then if there are any waiting events or notifications for that user, they can retrieve them when online also.
My concern is about the merging of data and the fact the local storage PK's will not be the same as the online PK's.
For example, user1 and user2 both just installed the app. They both create an event and invite each other to the event. Once they are both online their devices try to push the data to the online DB however there is a conflict with the PK used.
My question is: Can someone give me some guidance about how best to handle a situation like this? The app will be built using AS3 and Air and only for iOS and Android. There will be a MySQL remote DB with a PHP backend.
Any help is appreciated.
You could also send a time stamp of when it was sent to use with your PHP, where the request that got there last has an event sent back to notify the user (probably best with a push notification) that there has already been an event made.
Also not sure if you know already, but you can use NetConnection status to get a sense of when they connect to the internet.
localNc = new NetConnection();
localNc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
function netStatus(event:NetStatusEvent):void{
trace(event.info.code);
}

How to send notifications from an Android Phone to a website?

I am currently working on my project like Parental control. I am trying to find a way , that if there is any procedure or way to send a notification from an android phone to a website whenever the android phone sends/receives an SMS and dials/receives a call. On website , a database will be maintained for these notifications.
You could send a get request or post request to a website.
Sending POST data in Android
Android - Sending HTTPS Get Request
Just some examples. You will probably be looking for a restful api. I haven't read this, but it looks viable:
http://www.9lessons.info/2012/05/create-restful-services-api-in-php.html
I think you want to maintain database, based on mobile even. You can create API call, that will send data to database while any activity happened on mobile. That api will store notification on DB.
On web you can create AJAX call that will check in DB, if any new notification come or not, if new record found you can show it on website.
This is what I think the best way to do so...

Categories