How to Send Push Notification between Different Devices using OneSignal & Firebase - part 3
HTML-код
- Опубликовано: 18 мар 2017
- How to Send Push Notification to Different Devices using OneSignal - Firebase - part 3
Things to Remember:
--------------------------------------------------------------------------------------------------------
Use your own Logic to Target the Other Devices. You can use Device ID, Users Email ID, In my case i used just a simple case to point the two email ID.
--------------------------------------------------------------------------------------------------------
Like, Share & Subscribe for More applications..
You can Find Source Code in My Blog. if not then Comment With your Email ID..
Take a look at tutorial44286.blogspot.com/
GitHub:
github.com/Minsamin/Firebsase...
-----------------------------------------------------------------------------------------------------
-Music Credit: Royalty Free House (Deep, Tropical, Progressive, etc.)
• Royalty Free House (De...
Don't forget Post A Thanks :)
Sharing is Caring....
Sir you are just awesome. Great video sir. It helped me a lot. Thank you so much sir.
EVERYTHING WORKS FINE! You saved my life :)
Thanks for the feedback. Please subscribe to my channel. 😊
wasted 12 hours on other videos and you have solved my problem
Thanks, that helped me!
if(MainActivity.loggedin.equal())
here you put your email and i dont understand which emal is here shold be put??
great video worked thanks alot
My app crashes when i started it up. It crash on line 59(LoggedIn_User_Email = user.getEmail() ). The problem only occurs when I start the app and is not logged in. But since I was logged in on the app, and the app started without any problems. Please help me with the problem.
Ty alot! very useful!
+Daniel ng chiu loong you most welcome bro.
If My videos helped you, Please Subscribe :)
I worked on Source code and changed my compte ID, but the notifications for the old account of the owner of the code are still showing, is there a solution ...
Great video, Thanks. Are all the dependencies needed? in the blog you only have the java code so is there a way to get the rest of the code?
i just posted the code which in essential . you may have different layout that's why.
and all dependencies are needed for my 3 tutorials....
I will try to work it out in the next days. Will you make a video on how to send Push Notification to more then 1 device using queries?
you can use that code for send more than one device.. Specifically. Just set that device to different TAG.
you can see those tags on Onesignal Console..
Wow I got it to work. How would you modify the notification sound (for example) on the recivieving end?
+oz wilson follow onesignal guide page.. You will find your answers
Hi! I already have a populated firebase database. Even after adding the service to the project, I can't get the pre-filled data into the onesignal database(which is empty atm). Is there a way to do so?
Maybe you missed something. Data will show on onesignal console, on initialize of onesignal in java code... Check again.
When you trigger onClickListener, is the notification sent to every user in OneSignal?
How to send to an specific user?
Thank you!
+Fabio Munar i made a logic to send that notification to that particular email id.. Not for every one..
Make your own logic to change the id programmatically
So instead of target Tag user email, should I target Player ID?
+Fabio Munar yes you can...
thanks great video
+msdiidi91 tutorial44286.blogspot.in/2017/03/send-push-notification-to-different.html?m=0
If My videos helped you, Please Subscribe :)
i have angular backend.
i want to make function like send and request accept like facebook.
how to use one singal in this case?
when i logout i want to stop getting notifications from one signal how can i do that?
+Samin Ali Mondal How can I set variable instead of English Message?
+The Legend that I don't know. Check onesignal documentation. You can do more than I show in video. ☺️
Great video 10/10 top job - Cheers Jonathan Mallinson
+Asian Replicas Thank you 😊
Welcome, keep up the great work - Cheers
If My videos helped you, Please do Subscribe :)
After I Sign out, the app does not work. How can I fix it?
This tutorial is really helpful.
And The guy is very very cooperative.
I am gonna Subscribe your channel.
Thank You.
+eegleyez 03 you welcome 🙂
Is there any way to disable the dialogue and show a toast when app is open and notification is received.
Bcoz the dialogue interrupt user interaction he must dismiss it by pressing back button.
I want to disable it.
Guide me please.
+eegleyez 03 go through onesignal's documentation.
There is something to do this. I saw., but forgot.
Logic will be, if app is open show dialog, else show notification.. Google it. You will get solution.
Did u get any solution? I m facing the same problem
Akshay Shetty yes I did.
You have to implement openHandler and receivedHandler for one signal notification
If you really wanna help beginners you should upload this app on cloud or gitthub and share a link.
As you can see that every one need a source code from github or cloud soIf you really and successfully implement it then please share it.
I have implement your code there is no syntax error I have use all keys and ids app id app keys of my own firebase and one signal but Nothing works. From One Signal I got notification but from one specific user to user it doesnot works.
How do I change the notification icon from the bell to my logo
Great video thanks, is there an option to send Notification to the other user and on their device to show "username has sent you a notification would you like to accept it?" and the user to have the option to press Ok or cancel? So that they will show they have "accepted" or "rejected" the notification?
+George Kosmadakis
You welcome 🙂.
you can code that, send notifications with data, like sender username, or other information, on receiving notification, check the data, and do what ever you want to do, with some if else statements.
Go through the documentation of onesignal, you can know more about handling notifications...
Good luck 🤞.
Thanks for the reply!
In the method sendNotifications in the part of String JsonBody = ...+ "\"filters\": [{\"field\": \"tag\", \"key\": \"User_ID\", \"relation\": \"=\", \"value\": \"" + send_email + "\"}],"
Is it possible to use the user ID instead of send_Email variable? can i target users that i want to send notifications by user ID and not by user email?
+George Kosmadakis I think you can. Read onesignal documentation bro.
Can we follow this to send push notification to other applications as well, to the admin app?
Yeah, why not, but this tutorial is bit old. Maybe you need to refactor the little bit.
I managed to implement this but every time I send a notification the other user receives it but the sender's app is crashing.
The error I get is: "Failed to resolve target intent service, skipping classname enforcement | Error while delivering the message: ServiceIntent not found."
Could you please advise?
+Nicoleta Minoiu sorry, I am not familiar with this error. In my case it's working perfectly. No users reported this type of error. You can search Google for the solution. Thanks :)
Thank you. Unfortunately, Google doesn't help much...
+Nicoleta Minoiu check manifest file. Compare it to my manifest file, which I provided.
Something you missed I think.
i m getting the same error :#
10-12 13:59:16.256 3306-3306/com.example.ecommerce.firebasetutorial E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
--------- beginning of system
10-12 13:59:16.256 3306-3306/com.example.ecommerce.firebasetutorial E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
how can i choose the activity to open when i get notification ??????? pleaaase help
hi sir, i just wanna ask about this tutorial, because i haven't seen the dialog box after i received the notification, but i followed all the steps that you have demo to us.. thankyou so much sir
+android studio if app is in foreground, then you will see dialog box. If is in background, then you will get notifications.
sir i tried to run my application in foreground but still there is no dialog box I only received notification. thankyou for your response sir:)
Brother
How to send to all clients using application
How do we trust onesignal.com?? Is it safe to share our app user data with this site
?
Can i get notification when the app is close?
Again I have one issues create that when i want to running this prog App in my device moto(6.1) then it becomes to be crashing than please tell me that how to resolve this issues.& how can create two emulator at one time
+Aadarsh jha press control, click both devices from AVD dialog. It will run both. And for crash, check logcat. Find proper error for the crash, and search Google for solution.
thanks a lot for this help but I want to know that How can send my own data to other device in Notification(this tutorial only display the MainActivity name & English Message)
+Aadarsh jha change the data field from that snippet code. And also read documentation from Onesignal website.
You can do more cool stuff
How can I use player ID Instead of email to send push notifications??
String userId = user.getUID();
OneSignal.sendTag("User ID", userID);
Sir, how to write the if condition for selecting a specific marker of map. Means if(this marker is clicked) then send email to this user. Please Help Me.
First look some tutorial to implement map. Then add some, marker to the map. Now, you can set click listeners to, on marker click.. Now add logic.
@@SaminAliMondal Sir, I have implemented map, and added markers. But I am unable to write an if condition inside the sendNotification method. How would we do that?
This tutorial was helpful. How do I display a notification when my app is not running (I'm not talking about running a service in the background)?
+kedar nadkarny for get a notification when app is in background, a background service is needed.
But if app is not running, you will never get notifications..
Onesignal have background service. No need code for that.
It will do automatically for you, like this example.
Oh. How come I get notification from facebook and other services when they are not running?
+kedar nadkarny they are never stopped. if you stopped it manually, they trigger again.
Lol.
If your phone is rooted, then you can know how many services are running in background. At system level.
OK. I read an article in which they said that when you clear running apps like Fb and WhatsApp, they don't actually stop running because they have been whitelisted by the manufacturers. Whereas, apps which are made by small time developers get destroyed when you swipe them of running apps list. :(
+kedar nadkarny don't know about manufacturers.!
Sound interesting. Maybe true.
But swipe from recent apps is true for all apps, except system apps, and if there are any whitelisted apps.
can you send me Gradle of this tutorial please & not resolving this sign In Successful:false, W/TESTING: signInWithEmail:failed,
com.google.firebase.auth.FirebaseAuthException: This operation is not allowed. You must enable this service in the console.
at com.google.android.gms.internal.zzdke.zzak(Unknown Source) and W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found. please send me solution of this issue
+Aadarsh jha go to firebase console. Then authentication. Then enable email authentication or something like that.
If any problem then, watch my previous tutorial on firebase authentication.
Why used OneSignal and Firebase both for Notification, please explain this
+Ajit choudhary I haven't used firebase for notification 🔔
. Coz, Firebase doesn't have per user base notifications. It sends notifications from console. And sends to all users.
But onesignal have those features which I want for this demo.
I m a Beginner in Android, i followed your tutorial but there are more problems come like Google Play services out of date. Requires 11220000 but found 10298470. is there required updated Gradle & data not reached to Server to other Device. is that not send notification from device to device by only using Firebase Consol.
+Ajit choudhary this features are not present is firebase right now.
And should always update to latest...
Actually, you can do that using firebase functions. You need to store the token id of the user into the database and then with that token you can customize the notification and send it only to one user
+Radu Serse good to know that. Will test later. Thanks.
Crack!!!
Thank you so fucking much man. God bless!
+Daniel you welcome.
Like and Subscribe if this video helped you. :)
hay man must to say nice work
listen i tried to visit ur Blog but i didn't find the SEND_NOTIFICATION method
can u reply with the function code plz :)
tutorial44286.blogspot.in/2017/03/send-push-notification-to-different.html?m=1
private void sendNotification()
{
AsyncTask.execute(new Runnable() {
@Override
public void run() {
int SDK_INT = android.os.Build.VERSION.SDK_INT;
if (SDK_INT > 8) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
String send_email;
//This is a Simple Logic to Send Notification different Device Programmatically....
if (MainActivity.LoggedIn_User_Email.equals("user1@gmail.com")) {
send_email = "user2@gmail.com";
} else {
send_email = "user1@gmail.com";
}
try {
String jsonResponse;
URL url = new URL("onesignal.com/api/v1/notifications");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setUseCaches(false);
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
con.setRequestProperty("Authorization", "Basic YTUzMWE2M2UtMTZiYy00M2FhLWEyMjItYWQ5YWI1MDgzM2U2");
con.setRequestMethod("POST");
String strJsonBody = "{"
+ "\"app_id\": \"0523d5af-d75a-4916-a8dd-3e9109e0f10b\","
+ "\"filters\": [{\"field\": \"tag\", \"key\": \"User_ID\", \"relation\": \"=\", \"value\": \"" + send_email + "\"}],"
+ "\"data\": {\"foo\": \"bar\"},"
+ "\"contents\": {\"en\": \"English Message\"}"
+ "}";
System.out.println("strJsonBody:
" + strJsonBody);
byte[] sendBytes = strJsonBody.getBytes("UTF-8");
con.setFixedLengthStreamingMode(sendBytes.length);
OutputStream outputStream = con.getOutputStream();
outputStream.write(sendBytes);
int httpResponse = con.getResponseCode();
System.out.println("httpResponse: " + httpResponse);
if (httpResponse >= HttpURLConnection.HTTP_OK
&& httpResponse < HttpURLConnection.HTTP_BAD_REQUEST) {
Scanner scanner = new Scanner(con.getInputStream(), "UTF-8");
jsonResponse = scanner.useDelimiter("\\A").hasNext() ? scanner.next() : "";
scanner.close();
} else {
Scanner scanner = new Scanner(con.getErrorStream(), "UTF-8");
jsonResponse = scanner.useDelimiter("\\A").hasNext() ? scanner.next() : "";
scanner.close();
}
System.out.println("jsonResponse:
" + jsonResponse);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
});
}
If the video helped you, please subscribe my channel. Thank you 😊
i have error :
Error:Failed to resolve: com.android.support:customtabs:[26.0.0,26.1.0
How to fix it ?
+Kuhaku Dragon I don't know bro. Never faced that type of error. You can Google it..
Hi, do you know how to change the notification's icon? I need to know this. Thanks for the video :)
+Jhan Carlo Yturregui Mena yes you can. Go through the onesignal documentation... Search Google for that link. And you are good to go.
Thank you so much, I did it :)
+Jhan Carlo Yturregui Mena awesome :)
bro cna u send me the code for changing notificaiton icon? email :alienikki97@gmail.com thank bro
If My videos helped you, Please Subscribe :)
can i send notification more than one device by use of OneSignal or Not if yes then how can
+Aadarsh jha YES, you can.
Using onesignal Segments.
You have to go through Onesignal's documentation for this..
I already read that but i could not understand properly therefore i ask to you but you tell me again read doc this is not soln. please give me advice that h can i solve it
this is NOT RECOMMENDED. You are putting the REST API code in the app. At 15:49 on OneSignal dashboard you can read it very clearly : "Treat this like a password and do NOT use this KEY in your app"
It will work but someone can steal it.
How will I use the code, please
Is it android studio or what?
+Pet Lovers yes, it's android studio. Get source code from my blog, link is in the description of the video. In blog, Scroll down to the bottom of the page, and click on the older posts, then you can find source code.
What if I want to send push notification to the other device in other country? Do I have to consider something else here? I want to send notification to someone in the other country so bad
+Youngho Seo this code will works. Coz, it's based on the tag. Which I set to his emailid.
So, onesignal will send a notification to that app's user.
Watch the video again, and try to understand properly what is going on..!
Samin Ali Mondal thanks! I was wondering why the push did not turn up after I went abroad. Maybe I'm doing something wrong.
+Youngho Seo maybe. Check your code again.
Samin Ali Mondal I was wrong! Haha now everything works so well. thank you!
+Youngho Seo you most welcome ☺️
How I can set small icon and large icon in code to push Notification without using web?. Thank you so much!
+Trinhvanminh Vanminh I think you can, read onesignal documentation. You will get the idea. I already posted a link in comments here. Check that.
okay ! I'll try. Thank you !!
+Trinhvanminh Vanminh you welcome 🙂
Can i send notification to many devices instead of 1 only?
if can how do i do it?
+Jabez wong yes bro. It will need segments rather than id. Check onesignal's documentation..
Thanks:)
+Jabez wong you welcome 🙂
i can't find the method I should use with segments instead of " sendTag(.... , .....) "
can you help me ?
+pearl adams sorry, you have to read onesignal documentation for that bro. I got a job, so no time to make new videos and help others. I can just reply comments as soon as I get some time.
Is there a tutorial online for iOS?
+Daniel I don't know that.
I m using this tutorial in Android studio 2.3.2
bruh , i want to know how to send Notification to many people which install my app , do you have an idea ?
+hening pda yes you can do that. You need to use segments for that. Check one signal documentation. There you will get more information about this.. :)
okay i'll check it out
did you do it ?
i spent 2 days searching on it
Hi Hening, you can use onesignal.com and that a single line of code then its easy to push more than 500k devices
If this video helped you, please subscribe my channel. Thank you 😊
I am no use log in or registration,,,so i have no mAuth....how can i send notification???please help
Get onesignal's player ID, and send notifications as per id.. For more information please go through documentation of onesignal manual.
I read onesignal documentation but can't any solution...Please give simple hints according to you tutorial..
Thanks Samin it's wonderful. Please could you drop a tutorial on how to process message history and save it. i'd like to know your twitter or instagram handle if you don't mind
How to resolve this issues Attempt to invoke virtual method 'java.lang.String com.google.firebase.auth.FirebaseUser.getEmail()' on a null object reference please help me
+Ajit choudhary send snapshot of that error line.
can you tell me please that where user1@gmail.com & user2@gmail.com stored in the notification App and seeing properly in Onesignal interface whenever my email id seeing showing Null.
+Ajit choudhary watch the tutorial again. Try to understand that first.
only 3 files r show Java res & Mainfest file but not show any gadle file here
How can i replace English message with variable
+Phatcha you have to read onesignal documentation for that. I already posted a link somewhere in this video's comments.
Not able to see your coding video. try to zoom while creating video
geting notification but bo sound what is the error
i have forget to give notification sound permission i forget.. thanks every thing is fine...❤
Can you please tell me..why i am getting this error ---> "jsonResponse:{"id":"","recipients":0,"errors":["All included players are not subscribed"]}"
+Temp Pinnacle your query cannot find any registered device.
At first, run the app to 5hat device. Then that device will register to onesignal. Then if your query is OK, then you will get recipients..
Watch the tutorial again. And do step by step.
And the source code is given in my blog. Link is in the description of the video. Go to the blog and scroll down to the bottom of the page and click on older posts. Then You can find source code.
But i can see my registerd divices in OneSignel All user...Even i have set tag to them, still i am getting this error.
even i can send notification messages from oneSignel to all my Virtual Devices, but i want to send notifications from one device to another device..
+Temp Pinnacle that's what I already shown in the video bro. I think you miss some code on that push method. Check the code again and again, I also got error first time.. You need to understand that method,that code. Then you can do that as u wish. Some logical mistakes you have in your code.
please tell me one this..is this video have any concern with previous 2 parts..? i mean i can only want to send notification..so should i go thorough previous 2 parts before this one..?
How can i add title for my notification?
+Klajdi Bulku follow onesignal documentation for that bro. I can't remember.
I found it : + "\"headings\": {\"en\": \""+ title +"\"}," thnx
+Klajdi Bulku you most welcome ☺️
how can we send it to multiple emails?
you can call that method multiple time with different emails.
If My videos helped you, Please Subscribe :)
hi, thanks for the awsome tutorial. but i got this and i cant figure out what it is? i googled and cannot find any solution. - jsonResponse:
{"id":"","recipients":0,"errors":["All included players are not subscribed"]}
This the the reply from onesignal, as a json response.
It does not send notifications to other devices. Dashboard display all my users are subscribed. and here i get recipients as 0.
It's working here, and for others also. You probably missed something.
I figure out the issue.
"\"filters\": [{\"field\": \"tag\", \"key\": \"User_ID\", \"relation\": \"=\", \"value\": \"" + send_email + "\"}]," in this line of code the "User_ID" should be like this "USER_ID" . Thank you for this tutorial.
You are welcome. Hope you subscribe to my channel. Thank you 😊
Your blog is down. Please push your code into GitHub or some other place
tutorial44286.blogspot.com/
tutorial44286.blogspot.com/2017/03/send-push-notification-to-different.html
tnx so much.
+sayed amir ahmadi you most welcome. 😊
this is not work for me
music is too loud. you rarely say a word. and the code theme is dark when it should be light because the font size is small
where are parts 1 and 2 please ?
Others parts is not for notification purpose. There are some firebase tutorials, that I mentioned as part.
For notification, this video is all about.
code?
Check Description
tutorial44286.blogspot.com/2017/03/send-push-notification-to-different.html
Send tag to one signal is not working here
+raj kiran watch video again, don't skip any steps. I used this code 2 weeks ago. So I can confirm that, it's a working code.
Samin Ali Mondal i didn't say that your code is wrong ....Srry if you feel so..And ok I'll check your blog and I'll get back to you...Thank you for reply :)
+raj kiran you welcome 🙂
In my case it's working, but can't figure out what you have done wrong.
Saminali500@gmail.com
Where is Part-1,Part-2? Thanks
For push notifications, this video is enough. Other parts are related to firebase tutorials. You can check my firebase tutorial playlist in my channel for more information
part 1 & 2?
For push notifications, this video is enough. All parts are related to firebase tutorials, that's why I names as parts.. All video you can see in my channel.
@@SaminAliMondal tq
where is part 1 and part 2
All uploaded, and available in same playlist.
Link please
hi plz ur code not see good plz code screen do white
+Mr Tayyab Mughal watch in full HD. No one complaints about this till now ..
send me the code
Go to my blog. Link is in the description of the video. Then scroll down to the bottom of the page and click on the older posts and then you will see the source code
please send me Gradle file
+Ajit choudhary check my firebase chat tutorials. In video description you will get source code zip, and gradle file zip link...
can you send me link of Gradle please
+Ajit choudhary
You can Find Source Code here
drive.google.com/open?id=0B7Gop0B7KsnfZVZhRDNGWU5VUDA
Gradle Files
goo.gl/L6MPDo
All Files r Present there but Gradle File is not present so, please send me gradle file also
+Ajit choudhary check previous comment. I already sent both link.
Kindly create videos without music, its for learning, not for fun
+Waqas Ali I know, but I cannot talk fluently, stammering problem. People never accept that. That's why.....
Samin Ali Mondal Its 0hk bro, no one is perfact in all fields but i feel music between tutorial kind of confussing. By the i am s0rry if u dont like my suggestion
this is not a good tutorial! your just copy pasting it
+eurel odiaz if I have to wite the whole code in front of camera, people will never watch the whole video. That's why I wrote code before, and make videos for you after. Hope that's clear to you. :)
sorry im so desperate with my capstone, :( can you send the source code? your my last hope
advance thank you
+eurel odiaz open my blog. Link is in the description of the video. Scroll down to the bottom of the page. Click on older posts. Or something like that. There you can find source code. Thank you 😊
i cant go to the link.. i know it's too much but can you email me the project if possible? here's my email
eurel.odiaz@gmail.com, thank you
+eurel odiaz can't send you the whole project, already deleted.
This is the source code link.
tutorial44286.blogspot.in/2017/03/send-push-notification-to-different.html?m=0
I think in my firebase chat application tutorial, I posted a zip link in the description.
Probably there you can find the whole pro. Not sure. Take a look at that too.