Amazon SNS Mobile Push - How to send/publish to multiple endpoints? - php

I want to send messages to multiple users/Endpoints ARN selecting from MYSQL database without using Topic using PHP SDK.

Amazon Mobile Push can send notifications in two ways:
Push a message to a single end-point
Send a message to an Amazon Simple Notification Service (SNS) topic, and that topic pushes to multiple subscribed endpoints.
To send messages to multiple users/endpoints from a MySQL database, you would need an application that reads from the database, determines what message to send to whom, and then send that individual message to one endpoint. To send to multiple users, use an SNS topic.
See: Amazon SNS Mobile Push Notifications

Unfortunately - SNS allows publishing to multiple endpoints using topic. So you'll have to use that. Keep in mind though for the topic subscription will only work one call at a time for each end-point. It does not have bulk subscription to topic feature yet:
https://forums.aws.amazon.com/thread.jspa?messageID=639931&#639931

Amazon Mobile Push can send notifications in two ways :
Push notifications for a single device with Application single end- point ARN
Send a message to SNS topic and that topic pushed to all subscribed endpoint devices
So, better to use SNS Topic if you need to broadcast same message to multiple users device or, there is a other way to do it by using end-point ARN also. Simple you need to maintain all users information in your database and just trigger message by fetching all members from database and push message one by one to all members.
EG :
$users = all users information having user info and ARN
registered with SNS applications ARN;
foreach ($users as $user) {
//Call AWS SNS pushed code with user's end-point informations, It will
//automatically send all subscribed users in present in your database
//tables also with proper informations
}

Related

Bot replying to app_mention event in the wrong channel

I'm trying to work with the slack Event Subscription app_mention, but I'm having some issues.
My backend is PHP, and I'm using this class.
Basically, what's happening is, if I have my bot user in multiple channels and someone mentions the bot, it will only reply in a single channel.
For example;
I have the bot user in 2 channels
bot-testing
development
If I # mention the bot in the development channel, it will send it's reply in the bot-testing channel.
My code used to send the message:
$client->to('#' . $event['channel'])->send("Hi. I'm currently under development.");
and my $event variable looks like this:
{"type":"app_mention","text":"<#UFT4EG0Q7> test","user":"UAKTRFH41","ts":"1548783398.055200","channel":"GAMED4PK5","event_ts":"1548783398.055200"}
but decoded obviously.
Why is my bot not replying in the correct channel?
So based on my reading of the PHP client you're using, that's designed for use with Incoming Webhooks.
Incoming Webhooks have a 1:1 relationship with a conversation/channel, so you can't define the destination for your message in the payload you send to the API.
If you want to do that, you could try using one of the other PHP SDKs built by the community.

Send push notification to APP without device token or register id

I have already experienced to send push notifications to android and apple device with specific device token or registered id and I did use it in different projects, but this time I am just looking for a solution where I can send a push notification to APP means whoever installed the APP will get a notification.
Please let me know if this is possible and if yes then how.
Thanks
You need push tokens to send notification and there is no option to send push message to all devices without knowing their token . But you can send topic notifications if user has subscribed to that specific topic . You may need topic subscription to send push message to all subscribed users .
Client side you can subscribe to topic like
FirebaseMessaging.getInstance().subscribeToTopic("TestTopic");
find it here

Do I have any way or another service to push notification that have different message (payload) to different tokens in One http request?

My purpose: One Push Notification to iOS app, badgeNumber on device need to update based on each device's badge increment.
We knew that we can send only one message (payload) to different tokens
in iOS, We cannot update badge number even we receive remote notification when App is forced to close from background.
I want to use above method to send Different Badge Number to each device, since I get badge number for device from my DB Server.
I used FCM for iOS push notification
for Server-side, I use PHP
Some discussion(Android GCM - Send different payload to each user in registration_ids array )
said it's not possible, so is there any way or paid service?
Some said we need to send each payload to each device tokens using loop. Example, I have 1000 tokens, will APNS block my future request?
For my app's usage: around 50 push/day
Thank for your contribute.
Some notes to your comment:
You can update badge if the application is dead, but it cannot be a silent notification, if silent it will simply ignored. Using a "normal" notification with badge in payload you can, in fact update it even killed manually.
You must keep in database all the device token with user associated, and send individual notification, you can't send bulk message with different content (in this case with different badge).
No, it will not block, you can send for each one:
This is from another forum but can be used as reference:
According to the "Push Notification Troughput and Error Checking" section of this Tech Note:
https://developer.apple.com/library/ios/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG44
"There are no caps or batch size limits for using APNs."
"If you're seeing throughput lower than 9,000 notifications per second, your server might benefit from improved error handling logic."

How to send Gcm notification to one app to other

I am wondering if it is possible to send push notifications to different Android applications. I can already send a push notification in same application but I want to send notification to different applications of mine. I have user application and driver application. I need to send push notification when user create order and driver get notification that "A new order is come" after driver accept. Acknowledgement notification get back to user.
I am using two different Google API for both Application, I think, its not good way...
Please give idea about this. ? thx
What you want is possible and not that strange at all, you have two applications registered for push in the developer console with two projects ids and want each of your Android application to be able to receive notifications from both ?
If thats what you want its possible you just need to register to both sender ids in the android applications check.
https://developer.android.com/google/gcm/adv.html#multi-senders
basically:
...
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(context);
}
regid = gcm.register(SENDER_ID_ONE, SENDER_ID_TWO);
....
push notification with 2 different apps are possible,i make it one database for both apps for save token id, generate 2 push notification. its working fine

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.

Categories