I'm using Pushwoosh to send notification both under Android and iOS.
Now it's possible to send Custom data under the Additional data tab of the Send push web page.
So I put some like this
{"event" : "1234"}
on the Custom data field but I can't get this kind of data on the app.
This is what I get under Android
{
"title":"test 4",
"collapse_key":"do_not_collapse",
"from":"320152062216",
"onStart":true,
"foreground":false,
"p":"f"
}
This is what I get under iOS
{
aps = {
alert = "test 4";
sound = default;
};
p = f;
}
Is there anyone who has managed to make it work?
Thanks.
I think Stack might be not the best place for this, but custom data is available only on Premium accounts.
Related
Is it possible to cancel a pushed notification before displaying it on the users phone ?
I have some custom logic which decides whether a notification needs to be displayed/appear . Is it possible for me to control this behaviour from the client side ios/android code ?
Once a message is sent to Firebase Cloud Message, there is no way to cancel its delivery.
If your message contains only a data element and no notification, displaying the message is handled by your application code - so in that case you may be able to suppress its display there.
Although the best way is to handle this is to cancel it on backend side, you still can add UNNotificationServiceExtension and override the didReceive method:
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: #escaping (UNNotificationContent) -> Void) {
self.receivedRequest = request;
self.contentHandler = contentHandler
self.content = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let content = self.content {
// I had to check something inside the push itself
if let infoDictionary = content.userInfo {
// Check something inside the push notification
contentHandler(content)
return
}
}
// Otherwise, send an empty notification to the system and it will show nothing
contentHandler(UNNotificationContent())
}
I'm doing my final year project about flood push notification. Previously, a user will retrieve notifications whenever the value in database changes from 0 to 1. But right now,in my app, the user can choose which places he parks his car and he can retrieved status and notification based on the park's place whether it's zero or one. As for example, User A set his spinner value in Mid Valley and User B set his spinner value in KPS. User A will get notification when FLOOD_STATUS_MID_VALLEY is 1, while User B didn't receive any notifications because FLOOD_STATUS_KPS is still 0. Anyone can help me on how to send notification based on the spinner value in the app?
Screenshot of my app
Screenshot
below is the python code that running on server to send notification based on a value called "FLOOD_STATUS" in firebase database
from pusher_push_notifications import PushNotifications
config = {
'apiKey': "APIKEY",
'authDomain': "car-app-push-notification.firebaseapp.com",
'databaseURL': "https://car-app-push-notification.firebaseio.com",
'projectId': "car-app-push-notification",
'storageBucket': "car-app-push-notification.appspot.com",
'messagingSenderId': "596729642105",
'appId': "APPID",
'measurementId': "G-9LMJGS1BDW"
}
firebase = pyrebase.initialize_app(config)
db = firebase.database()
beams_client = PushNotifications(
instance_id='49f62b05-bd81-4040-ab57-80afa56a8680',
secret_key='SECRET KEY',
)
def stream_handler(message):
print(message)
if(message['data'] is 1):
response = beams_client.publish_to_interests(
interests=['hello'],
publish_body={
'apns': {
'aps': {
'alert': 'Hello!',
},
},
'fcm': {
'notification': {
'title': 'Alert!',
'body': 'It is starting to flood, please remove your car immediately!',
},
},
},
)
print(response['publishId'])
my_stream = db.child("FLOOD_STATUS").stream(stream_handler,None)
As this is your FYP, I won't provide any code for this.
When a user changes where they parked, you will want to change their device interest to match the relevant location.
When the FLOOD_STATUS is updated to 1 for a given location, you send the notification to the matching interest.
I suggest that, when the user A select the MID_VALLEY in the Spinner you send the selected value to the server. I recommend you to have a look on this tutorial to see how to get the selected value from Spinner
At server side, when the FLOOD_STATUS_MID_VALLEY is 1 you only send the notification to the user A(because you knew the FCM token of the user A).
If you want to custom the item of Spinner you can watch this tutorial.
I am a newbie on parse server and have been using it with my android app. But I am having trouble with implementing push notifications. I do not know how to get logs so any guidance will be much appreciated! The installation class does not contain any "GCMSenderId" or "deviceToken".
Here is how I set up parse server to implement push notifications.
Parse Sever : 2.2.7
1) Developer Console
a) I create a new project using the new console and clicked on the overflow menu --> Project Info and got my project number.
b) Then I went to the "Credentials" page and clicked on Create Credentials --> Api Key --> Server Key and left everything default and clicked create.
c) I got the key for my project. Let it be "MY_API_KEY".
2) Now I setup my parse server app to use this api key and project number as you can see from the image.
enter image description here
3) Now I setup my android app manifest accordingly as you can see from the picture below.
enter image description here
I also added ParseInstallation.getCurrentInstallation.saveInBackground();in my app's Application class.
I am trying to send notifications using the parse dashboard
Please provide any help if possible, thanks!
to send push notification from parse server you have to implement cloud code
in Javascript or another programming language.
below is some code in JS to send push notification to a user
function(objectids,msg) {
var pushQuery = new Parse.Query(Parse.Installation);
msg.default="default";
pushQuery.exists("deviceToken");
pushQuery.containedIn('userObjectId',objectids);
try
{
Parse.Push.send({
where: pushQuery,
data: {
alert:msg.msgInfo,
str:msg,
sound:msg.default
}
}).then(function() {
console.log("push successfully sent");
}, function(error) {
console.log("error while send pn:"+error.code+":"+error.message);
throw "Push Error " + error.code + " : " + error.message;
});
}catch(error)
{
console.log("error while send pn:"+error.code+":"+error.message);
}
}
i am trying to find a way to send SMS and make a phone call from a samsung gear s app.
the documentation is mostly missing and searching for this did not lead to much findings.
has anybody worked with that? is it at all possible?
as an alternative, if the app cannot send SMS or make the call, is it possible to start the default apps (similar to Android intent for SMS/Phone app or iOS openURL).
thanks.
#memical - I have found a workaround to launch message/sms app using the app id.
<p onclick="hackSMS();">Send SMS</p>
<script>
function hackSMS() {
tizen.application.launch("com.samsung.message", function(){console.log ("Launched")});
}
</script>
Remember to add this http://tizen.org/privilege/application.launch priviege in your apps config.xml
Note: I tried other methods also like using exposed tizen platform api's for web apps to launch some predefined app control. But it is working for Call and not for sms.
here is what i find so far:
to make a call from a Gear S app use the following code:
var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/call", "tel:001....");
tizen.application.launchAppControl(appControl, null,
function() {
console.log("ok");
},
function(e)
{
console.log("error: " + e.message);
},
{
onsuccess : function()
{
console.log("ok 2");
},
onfailure : function(er)
{
console.log("error 2: " + er.message);
}
});
sending SMS is not possible at this time.
There is no messaging API implemented on Tizen for wearable devices. You can check it yourself by calling:
console.log(tizen.messaging);
It will return 'undefined'
It means that you can't programmatically send or read an SMS or an email from your wearable device using Tizen messaging API.
To open the app for make a call try this code:
Uri number = Uri.parse("tel:"+telNumber);
Intent openCallIntent = new Intent(Intent.ACTION_DIAL, number);
startActivity(openCallIntent);
To make a call:
Uri number = Uri.parse("tel:"+telNumber);
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(number);
startActivity(callIntent);
To send an sms:
Intent sendSmsIntent = new Intent(Intent.ACTION_VIEW);
sendSmsIntent.setType("vnd.android-dir/mms-sms");
sendSmsIntent.putExtra("address", telNumber);
sendSmsIntent.putExtra("sms_body","Whatever you want");
startActivity(sendSmsIntent);
Similar questions to this one are already answered in stackoverflow
Try this which is very simple as compare to using the platform APIs.
http://www.w3.org/TR/mwabp/#bp-interaction-uri-schemes
The most broadly supported scheme is tel: as described in RFC3966
[RFC3966]. Code such as the following can be used to enable
"Click-to-Call":
[PHONE-NUMBER]
Note that [PHONE-NUMBER] should always be entered using the full
international prefix (e.g. +1-201-555-0111) to ensure that it works
outside of its home country.
Similarly RFC5724 [RFC5724] can be used to send a GSM SMS (text
message) as follows:
[PHONE-NUMBER]
Note that at the time of writing support for this RFC is limited and
device compatibility should be verified before deployment.
I work to develop a chat app with android on node.js server.I made a simple chat app.But everyone gets involved in the same room.I want to make a chat between only two people.How can I do that? What information should I send to the server?such as sender_name,receiver_name,message as a json format.
-How can I to do list online-users?
-And How can I start a chat between only two people?
What are the requirements for it?
This might help:
I'd recommend setting up namespaces for each room you have your chat in. I did something similar in my own code. Note: Rooms and namespaces are a little different from each other in socket.io itself (socket.io has both: http://socket.io/docs/rooms-and-namespaces/).
In the Server code:
I have a method under socket.on('connection') that is similar to
socket.on('groupConnect', function(group){
var groupNsp = io.of('/' + group);
}
This essentially makes sure that a namespace is exists under the name of the desired one. It doesn't mess it up or reset the namespace when it is called again.
Then for receiving the messages:
socket.on('message', function(data){
var msg = data.msg;
var nsp = data.nsp;
io.of(nsp).emit('message', msg);
}
You could also add the nsp to the data you have already and then just send the data again to the clients.
Then, in the client code:
var socketOut = io.connect('http://yourdomain:1337/');
var someGroupOrMethodToGetGroup;
socketOut.emit('groupConnect', someGroupOrMethodToGetGroup);
var nsp;
setTimeout(function(){
socket = io.connect('http://yourdomain:1377/' + someGroupOrMethodToGetGroup);
socket.on('message', function(msg){
displayMessage(msg);
}
nsp = '/' + someGroupOrMethodToGetGroup;
}, 1500);
Then in my displayMessage code I have:
socketOut.emit('message', { msg: desiredMessage, nsp: nsp });
From another answer of mine (https://stackoverflow.com/a/24805494/3842050).