I'm currently trying out GCM on android with the DemoActivity project that I downloaded from android SDK. There are a couples of question regarding this whole GCM stuff. Correct me if I'm wrong.
Based on my understanding, what we needed to register the android device for GCM is just Sender_ID and Server_URL? Server_URL is based on the URL of my 3rd Party Application Server for example http://localhost:8080/gcm_test. As for Sender_ID is basically Google API's Project ID.
Do I need to send the registration ID from the android device to the server side and store it in server side database or something like that?
In order to send message from server to the android device, we needed API key and the android Registration ID?
How to configure on the server side in order to send message?
1)Right
2)Yes.You need that whenever you need to send a Push Notification to a particular device.The server identifies this device using a registeration id.
3)You need the Google App Id you got when you created the project and the registration Id you saved on the backed.
4)For ASP.NET look at this.
string GoogleAppID = "google application id";
var SENDER_ID = "9999999999";
//......
//......
AndroidGCMPushNotification apnGCM = new AndroidGCMPushNotification();
string strResponse =
apnGCM.SendNotification(devRegId,
"Test Push Notification message ");
Related
i have users Uid in an 'users' array as ['uid1','uid2'] now i will be sending notifications to these users in cloud function?
exports.sendNotificationFromCr = functions.database.ref('/cr/{crUid}/notifications/{notificationid}/').onWrite(event => {
const uid = ['uid1','uid2']; // some how i get this.
// some work to send notifications
// to all tokens of uid1 and uid2.
}
here is the database structure:
users/
uid1/
name:{name}
FCM-key/
token1:true
token2:true
uid2/
...
FCM-key/
token3:true
using ['uid1','uid2'] i want to send notification to all 3 tokens in my database. how to do that?
If you're using something like firebase. Then you would want to have a notifications database model, that has the userId, the notification title, body and perhaps image, also a seen flag (true or false).
You would then post notifications either from your clients or from your cloud server code into the database. One per client/notification. If you have thousands of users you would use some sort of server-side cronjob, to offload this so that it runs outside of say your client to server API.
On the clients, you would be listening for new rows in that model filtering on the userId and when they appear, display them to the client in your UI. Once the client has seen the notification you would mark it as seen on the client.
Without knowing what platforms, code base, DB you are using it's impossible to explain in code terms how this would be done.
There are various API's for IOS and Android and Firebase that resolve this.
I am using PushSharp library. I am able see deviceToken in the sample code https://github.com/Redth/PushSharp
Can anybody help me how to get that ? PushSharp sample code doesn't explain that
apnsBroker.QueueNotification (new ApnsNotification {
DeviceToken = deviceToken,
Payload = JObject.Parse ("{\"aps\":{\"badge\":7}}")
Same for Android, How can I get the Registration ID's
foreach (var regId in MY_REGISTRATION_IDS) {
// Queue a notification to send
gcmBroker.QueueNotification (new GcmNotification {
RegistrationIds = new List<string> {
regId
},
Data = JObject.Parse ("{ \"somekey\" : \"somevalue\" }")
});
}
I am sending push notification via my service layer which is developed using webapi. Please suggest.
The deviceToken (aka Registration Token) is generated on the client app side.
For GCM - Android, to retrieve the registration token, you'll have to call InstanceID.getToken(). See the official documentation -- Setup a GCM Client on Android:
For GCM - iOS, something similar needs to be done (with further settings needed to connect with APNs). See the official documentation -- Setup a GCM Client on iOS. The guide can be adjusted for Objective-C or Swift.
With that said, the code you referred to is under the section labeled APNS Sample Usage, so I guess it's also safe to refer to this post. Or directly from the Apple Developer site if you plan to directly use APNs without GCM.
PS: If you intend to use GCM, I would strongly recommend that you proceed with using the newer version, which is firebase-cloud-messaging. Official docs here.
I'm trying to use the Twilio Client on an AngularJS app. Server side is on Laravel PHP. I tested the Quickstart for PHP and I'm trying to adapt it to this actual case.
I created an endpoint on Laravel to get a capability token on angular -I'm getting it already- then:
vm.token = response.token;
vm.message = response.identity;
Twilio.Device.setup(vm.token);
Twilio.Device.ready(function(device){
vm.message = "Twilio.Device ready";
});
Since nothing happened, I placed a button to verify the status of Twilio.Device
function deviceStatus(){
vm.status = Twilio.Device.status();
}
The status is always returning OFFLINE. I already verified account id, token and Twiml app sid and everything is ok.
Am I doing something wrong? missing some step?
Browser only allows media control when your site or domain has SSL, which access media controls like audio or video io
If insecure the connection will be terminated.
I want to Send push notifications from meteor website to android application using Google cloud messaging.
The way I've done it is to use the package raix:push.
To do this, first install the package, then set up a config.push.json file in your root directory. This file contains the settings for the push notifications. The most basic file you can have that allows you to use Google cloud messaging is just:
{
"gcm":{
"apiKey":"yourApiKey",
"projectNumber": 000000000
}
}
Then you can send a push notification by calling a meteor method:
Meteor.methods({
"sendPush": function(title, text, userId){
Push.send({
from: 'yourName',
title: title,
text: text,
query:{userId: userId}
});
}
});
and also calling:
Push.allow({
// Change this to determine whether the user with id userId can send
// the notification
send: function(userId, notification) {
return true; // Allow all users to send
}
});
on the server.
The above method would send a push notification to a user with _id equal to userId. You can make the query more complicated to send multiple notifications at once, just keep in mind that the field with the user's id is called userId, since this package creates a new collection to emit notifications.
This package is documented quite well: https://github.com/raix/push. Just follow the instructions for android, and take a look at the simple example.
If you don't have an api key or project number, you can follow the instructions in the documentation to set up Google cloud messaging.
I have developed the Phonegap App.
I want to identify that app is installed in user mobile.
When user install app, h/she will register with our API server to use the app. First screen of APP is registration form.
We have maintained the UNIQUE user id so that we can identify the device and user.
I have used the push notification in APP.
Now I want to send the request to server from mobile that application is in mobile.
I want to code such that mobile will send the request to API server after specific interval of time. Time will be in days.
And the process to send request to server must run in background.
Can anyone help regarding this??
If user deletes your app,how can you send request from mobile to your server? I think it'll be deleted with total instances so that there won't be any code with whom you can send request. If you found any way to send request after deletion, here is the code for checking if your application exists or not. It's native coede.
protected boolean isAppInstalled(String packageName) {
Intent mIntent = getPackageManager().getLaunchIntentForPackage(packageName);
if (mIntent != null) {
return true;
}
else {
return false;
}
}
packageName is your app package name.