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.
Related
I use azure-graph in my Node.js project:
const MsRest = require('ms-rest-azure');
const credentials = await MsRest.loginWithServicePrincipalSecret(keys.appId, keys.pass, keys.tenantId, { tokenAudience: 'graph' });
const GraphkManagementClient = require('azure-graph');
const client = new GraphkManagementClient(credentials, subscriptionId);
return client.users.get(principalID);
I want to use the Azure SDK also to send emails.
I know how to do that in low level using the API directly:
But I want to do it via the SDK like the rest of my project.
My problem is, I have not found any method for sending an email in the docs: azure-graph package. I need a method that allows me (with the proper privileges of course) to send email as any user in the organization.
You can use the Graph JavaScript SDK which is a wrapper around the Microsoft Graph API that can be used server-side and in the browser to send mails to users. Please refer to Graph Javascript SDK to learn more about the same. Also, refer to nodejs-connect-sample to use Microsoft Graph API and the Graph JavaScript SDK to send an email.
this is my first post so please go easy on me!
I am a beginning developer working with javascript and node.js. I am trying to make a basic request from a node js file to facebook's graph API. I have signed up for their developer service using my facebook account, and I have installed the node package for FB found here (https://www.npmjs.com/package/fb). It looks official enough.
Everything seems to be working, except I am getting a response to my GET request with a message saying my appsecret_proof is invalid.
Here is the code I am using (be advised the sensitive info is just keyboard mashing).
let https = require("https");
var FB = require('fb');
FB.options({
version: 'v2.11',
appId: 484592542348233,
appSecret: '389fa3ha3fukzf83a3r8a3f3aa3a3'
});
FB.setAccessToken('f8af89a3f98a3f89a3f87af8afnafmdasfasedfaskjefzev8zv9z390fz39fznabacbkcbalanaa3fla398fa3lfa3flka3flina3fk3anflka3fnalifn3laifnka3fnaelfafi3eifafnaifla3nfia3nfa3ifla');
console.log(FB.options());
FB.api('/me',
'GET',
{
"fields": "id,name"
},
function (res) {
if(!res || res.error) {
console.log(!res ? 'error occurred' : res.error);
return;
}
console.log(res);
console.log(res.id);
console.log(res.name);
}
);
The error I am getting reads:
{ message: 'Invalid appsecret_proof provided in the API argument',
type: 'GraphMethodException',
code: 100,
fbtrace_id: 'H3pDC0OPZdK' }
I have reset my appSecret and accessToken on the developer page and tried them immediately after resetting them. I get the same error, so I don't think that stale credentials are the issue. My
console.log(FB.options())
returns an appropriate looking object that also contains a long hash for appSecretProof as expected. I have also tried this code with a number of version numbers in the options (v2.4, v2.5, v2.11, and without any version key). Facebook's documentation on this strikes me as somewhat unclear. I think I should be using v2.5 of the SDK (which the node package is meant to mimic) and making requests to v2.11 of the graph API, but ??? In any case, that wouldn't seem to explain the issue I'm having. I get a perfectly good response that says my appSecretProof is invalid when I don't specify any version number at all.
The node package for fb should be generating this appSecretProof for me, and it looks like it is doing that. My other info and syntax all seem correct according to the package documentation. What am I missing here? Thank you all so much in advance.
looks like you have required the appsecret_proof for 2 factor authorization in the advance setting in your app.
Access tokens are portable. It's possible to take an access token generated on a client by Facebook's SDK, send it to a server and then make calls from that server on behalf of the client. An access token can also be stolen by malicious software on a person's computer or a man in the middle attack. Then that access token can be used from an entirely different system that's not the client and not your server, generating spam or stealing data.
You can prevent this by adding the appsecret_proof parameter to every API call from a server and enabling the setting to require proof on all calls. This prevents bad guys from making API calls with your access tokens from their servers. If you're using the official PHP SDK, the appsecret_proof parameter is automatically added.
Please refer the below url to generate the valid appsecret_proof,and add it to each api call
https://developers.facebook.com/docs/graph-api/securing-requests
I had to deal with the same issue while working with passport-facebook-token,
I finally released that the problem had nothing to have with the logic of my codebase or the app configuration.
I had this error just because I was adding intentionally an authorization Header to the request. so if you are using postman or some other http client just make sure that the request does not contain any authorization Header.
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'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 ");
I am displaying a list of tweets in my BlackBerry WebWorks application that the user should be able to share via Twitter.
I want to use Twitter's native BlackBerry client, and am calling it via an invoke object. I can launch the Twitter application fine, but does anyone know what parameters are needed to skip directly to sharing content from my application?
I am using the following to successfully invoke the Twitter client:
try{
var params = new Array();
var args = new blackberry.invoke.JavaArguments('net_rim_bb_twitter', params);
blackberry.invoke.invoke(blackberry.invoke.APP_JAVA, args);
}catch(e){
alert("Could Not Invoke App: "+e.name+" : "+e.message);
}
Thanks everybody!
From WebWorks in order to invoke other application you need to use JavaArguments (as you do), but don't add parameters as it won't work use only module name:
new blackberry.invoke.JavaArguments('net_rim_bb_twitter');
This way the code will try to invoke 'net_tim_bb_twitter'.
Looking in BB's github and how JavaArguments are implemented - it takes the first parameter and creates a URL query from the Array arguments. If you add parameters like ["par=val","par2=val2"] then the code will try to start 'net_rim_bb_twitter?par=val&par2=val2" which won't start anything if not specified by the OS or the app. The idea with parameter is to invoke apps that are listening for URLs.
Using without parameters will just start the app but it won't prefill the desired fields within the app, so you need to create a screen in your app to post to twitter or just use the web intents https://dev.twitter.com/docs/intents and BrowserArguments to start nice little twitter web app prefilled with data from your web app.