One Signal Push Notification? - android

I have made movie review app on android.Users create an account with firebase authentication and review movies and rate them.Admin of app can add new movies.
My question is how can I(admin) send a notification to all users (of firebase) whenever I added a new movie?And I want to use one signal push notification.
Please Help me.

Using Tags its possible to send the notification to all users.
1.Primarily you have create a channel eg: allusers from mobile end need to register
JSONObject tags = new JSONObject();
tags.put("allusers", "1");
OneSignal.sendTags(tags);
2.From server end who are all registered in the tag allusers=1 ..Notification will send to all the users
Sending Push from serverside
https://documentation.onesignal.com/reference#create-notification

Related

How to sent push Notification to all users from firebase when new data add on Database

I am trying to trigger database by node.js . But i did not found any solution for this problem. Once I heard to store the device token for the sending notification.But it was for the device to device sending notification.If I sent notification for all users then should i store the device token for all users??
database tree in firebase
You can send push notification to all the user without saving device token.
For this you need to add following line in onReceive method:
FirebaseMessaging.getInstance().subscribeToTopic('news');
Then you can send push notification to that topic, it will be sent to all the user who are registered with that topic.
Note : Similarly the client can unsubscribe from a topic by calling unsubscribeFromTopic() method.
FirebaseMessaging.getInstance().unsubscribeFromTopic('news');

handling token changes in notification groups fcm

I have implemented Fcm in my App and thats working great.. In My app i am creating notification groups by
$data = array();
$data["operation"] = "create";
$data["notification_key_name"] = "gcm";
$data["registration_ids"] = array("token");
and iam successfully received my notificationkey for frequent use... and if the token changes to another should i remove the tokenid from the notification group and add the new one everytime ?? or fcm will take care of it???
Yes. It's the developer's responsibility to manage these changes in the Device Group Messaging (see my answer here).
You'll have overwrite/replace the old token with the new one.

Push notification for android app by GCM

I am working on android app for events reminder , this app only display event as list and details about it .. some event's date is change .
I need to push notification to remind a user about event date
I'am Confused when read about Google Cloud Messaging ( GCM )
Is it necessary to request from the user to enter name or email through the application ? I don't need that !
where can I write a new notification "message" to send it ?
Thank you ,
The requirement is simple.
You need to generate gcm token from each of your client.
Client A installs your application and upon launch/login(wherever it fits in your business logic) you will try to generate this gcm token(let us say 10000 is the generated token) . And you need to send this token to your server to store for using it in future communication. when you want to communicate with this client A, you need to tell gcm server,
Hey Gcm server, send mobile with gcm token 10000 the following message "Event time updated"
So if client b installs, it will generate its gcm token and send it to server in same way.
In case you have user login or some way where each user can be identified uniquely, it is recommended to store it along with user details. (along with name, unique id, etc... )
If you do not have login, you can still send token to server and store but what you loose out is the cases where You want to send update to Client A but not B.
Coming to code point of it.
Client code:
For generating gcm token:
https://github.com/googlesamples/google-services/tree/master/android/gcm
after you generate you need to send this token to server
Server code:
server receives the token and stores.
When you want to send a particular message in later point of time, you can send json data or plain message to client.
For example, Following is the python example.
import gcm
response = gcm.json_request(registration_ids=reg_ids, data=in_data, delay_while_idle=False)
Hope this helps.

sending push notification to multiple users using Parse in android

I want to send push notification to multiple users using parse backend. can i target a friends with Facebook id without creating channel?(in my app i integrated Facebook)
if not possible send me code with creating channel
Parse has different possibilities depending on which kind of account you have. I assume you have the free one so you CANNOT send push notifications to specific or multiple users with this kind of account. BUT you can send them through the website controller to just iOS or Android users which is the only option you have with the free account.
I actually encourage you to use channels to do so. I assume you already have the correct initializations as explained in the parse website (https://parse.com/docs/android_guide)
// Create our Installation query
ParseQuery pushQuery = ParseInstallation.getQuery();
pushQuery.whereEqualTo("channels", "Giants"); // Set the channel
pushQuery.whereEqualTo("scores", true);
// Send push notification to query
ParsePush push = new ParsePush();
push.setQuery(pushQuery);
push.setMessage("Giants scored against the A's! It's now 2-2.");
push.sendInBackground();
I ultimately reccomend you to read this guide: https://parse.com/docs/push_guide#sending-queries/Android

Android PushNotification From Json URL

I have a Json URL, which contains data about Latest Job Postings, I am successfully parsing the Json URL and able to display the top job postings in my ListView.
But my requirement is to create a push notification, so that whenever a new job is posted, the user should be able to get a notification on device.
I have followed this: http://www.vogella.com/articles/AndroidNotifications/article.html
But I don't know how to get notifications in my case.
Could anyone help me?
Issue:
Give push notification to user's device about the updated data even when application is in background mode.
Solution:
Upon successful insertion of new data in your database (which is going to give updated set of data to your JSON request) , just call the file which send GCM push notification to all your users.
Reference:
GCM docs
GCM push-notification using php server
In context of implementation presented in demo app of 2nd link,
upon successful insertion,you can call send_message.php file,but make sure that $regId and $message should be retrieved from your database
You have created ActionBar Notifications for your app, but now you need to create the ability to receive notifications from a web client, instead of going to find them yourself from the URL.
To create a push notification you would need to have a constant thread (BroadcastReceiver) on the device that is waiting for the notification from the sever.
Google 'Cloud to Device Messaging' is the simplest way to do this.
This is a good link with lots of info on how to do this :
http://blog.mediarain.com/2011/03/simple-google-android-c2dm-tutorial-push-notifications-for-android/
If you require these notifications to be displayed on the device even when the application is not running (which seems to be the case from what you describe), you can use Google Cloud Messaging.
You would need a server that would poll the Json URL for updates, and send a GCM message to all the devices where your app is installed once such an update is detected.
Your app would have to register to Google Cloud Messaging and send the Registration ID received from Google to your server.
When your app receive a GCM message, you would create a notification and when the notification is tapped, you would start the activity that loads the data from the JSON URL.

Categories

Resources