Push Notifications in Smartface App Studio - smartface.io

I am trying to implement Pust Notifications using Smartface App Studio.
I followed the link: http://www.smartface.io/developer/guides/advanced/push-notifications/
But, i stuck up with following.
1. Where can i find the devices which are registered with their device tokens by Notifications.remote.registerForPushNotifications() method.
2. How to get access_token to push the notifications from smartface api.
Can any one help me to figured out these? Thanks in advance.

For IOS below code works for me. I think android have changed for 4.5
var registerParsePush = new SMF.Net.WebClient({
httpMethod : "POST",
URL : "https://api.parse.com/1/installations",
contentType : "application/json",
requestHeaders : ["X-Parse-Application-Id: f5Y4tmDdKOYm5YdKDdDV8W6LDfviqFaCfhMgmxx", "X-Parse-REST-API-Key: PqbhEDYJcXP3xWmWRB6PBuzfIz4OIq0tK4V3dpxx", "Content-Type: application/json"],
onSyndicationSuccess : function (e) {},
onServerError : function (e) {}
});
Notifications.remote.registerForPushNotifications({
OnSuccess : function () {
var pushToken = Notifications.remote.token;
var req = {
"deviceType" : "ios",
"deviceToken" : pushToken,
"channels" : [
""
]
};
registerParsePush.requestString = JSON.stringify(req);
registerParsePush.run(true);
},
OnFailure : function () {}
});

Related

Sending voip push notification from one signal triggered firebase cloud functions

I`m trying to send Voip push notification from one signal triggered by firebase cloud functions. So far it being able to send normal message push notifications from one signal to IOS devices using firebase cloud functions with below code.
var sendNotification = function(data) {
var headers = {
"Content-Type": "application/json; charset=utf-8"
};
var options = {
host: "onesignal.com",
port: 443,
path: "/api/v1/notifications",
method: "POST",
headers: headers
};
var https = require('https');
var req = https.request(options, function(res) {
res.on('data', function(data) {
console.log("Response:");
console.log(JSON.parse(data));
});
});
req.on('error', function(e) {
console.log("ERROR:");
console.log(e);
});
req.write(JSON.stringify(data));
req.end();
};
var message = {
app_id: "*********************",
contents: {"en": "English Message"},
include_player_ids: ["******************7b0bdc38"]
};
sendNotification(message);
Does anyone know how to send Voip push notifications from one signal using firebase cloud functions??
(If the above code is required to change some part of it, it would be very thankful telling me where it is.)
As per one signal documentation (https://documentation.onesignal.com/docs/voip-notifications) you are missing the DEVICE_VOIP_TOKEN that you should have received from the iOS application.
Please try adding that and let me know, think of adding the exact error message if any.

Response with status: 0 for URL: null

I have a service that do post. The service is being hosted in another machine. When I tried to post using Postman, it works fine. Now, when I tried to post using my Angular2 app which is run in another machine I got an error "Response with status: 0 for URL: null." The code in my angular service is as follows:
postQuestions() {
var json = JSON.stringify({
"TestInfo_FK" : "612",
"Resource_FK" : 0,
"QuestionNo" : 22,
"ContentType" : "HTML",
"Content" : "This is the question from Jason",
"NoOptions" : 4,
"OptionLayout" : "Vertical",
"Answer" : "A"
});
var url = 'http://my.service.net/api/ONLINE/Question';
var params = 'json=' + json;
var headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Access-Control-Allow-Origin', '*');
return this._http.post(url, params, {
headers: headers
})
.map(res => res.json());
}
how to solve this issue?
This situation arises when your hosted service is not able to be accessed via cross origin(CORS) .So if u you are accessing Spring Rest service then use #CrossOrigin annotation on service.
OR use
flask-restful to build remote API
from flask_restful.utils import cors
from flask_restful import Api
api = Api(app, decorators=[cors.crossdomain(origin='*')])
I found out what was causing the issue.. Its a server side issue. You need to set the CORS middleware first then the remaining API middlewares.
Please note i am working with Laravel 5.6 + Angular 5
Wrong Code
'api' => [
'throttle:60,1',
'bindings',
\Barryvdh\Cors\HandleCors::class,
],
Currect Code
'api' => [
\Barryvdh\Cors\HandleCors::class,
'throttle:60,1',
'bindings'
],

How to create persistent rooms in openfire using strophe?

I'm using the following iq message to create persistent rooms in openfire:
var configiq = $iq({
to : chatObj.getActiveChatRoomName() + "#" + chatObj.groupChatService,
type : "set"
}).c("x", {
xmlns : "jabber:x:data",
type : "submit"
}).c('field', {
"var" : "FORM_TYPE"
})
.c('value').t("http://jabber.org/protocol/muc#roomconfig")
.up().up()
.c('field', {
"var" : "muc#roomconfig_persistentroom"
})
.c('value').t("1");
chatObj.connection.sendIQ(configiq.tree(), function () {
console.log('success');
}, function (err) {
console.log('error', err);
});
But, I am getting the following error:
error <iq xmlns=​"jabber:​client" type=​"error" id=​"1356:​sendIQ" from=​"msrtc0711#conference.stslp239" to=​"ashishjmeshram#stslp239/​ax8nb2atg1">​<x xmlns=​"jabber:​x:​data" type=​"submit">​…​</x>​<error code=​"400" type=​"modify">​<bad-request xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-stanzas">​</bad-request>​</error>​</iq>​
Using the Strophe.muc plugin is easier:
1) firstly join the room (this creates an instant room):
connection.muc.join(room_jid, nick);
2) then create a "configured room", eventually with a subject and a description associated:
var config = {"muc#roomconfig_publicroom": "1", "muc#roomconfig_persistentroom": "1"};
if (descr) config["muc#roomconfig_roomdesc"] = descr;
if (subject) config["muc#roomconfig_subject"] = subject;
connection.muc.createConfiguredRoom(room_jid, config, onCreateRoomSuccess, onCreateRoomError);
A working example is available here: http://plnkr.co/edit/Mbi15HDZ2yW5vXskS2X6?p=preview

Paypal Api is not working for Tizen tv

Paypal Rest Api is not working for Tizen tv while its working fine on rest client.
Neither success nor failure function is called in Tizen tv.
Changed the url other than paypal its working fine. Also tried with ajax no changes found.
here is the sample code for it.
Get:
var request = $http({
method : "get",
url : "https://api.sandbox.paypal.com/v1/payments/payment",
headers : {
"Content-Type" : "application/json",
"Authorization": "Bearer A101.FfLKjOmGx-80JU9h9ACDqrm0-dSg5pvlUsMnz2Slsb9hbSZSNQXQ7c653uc0XEYS.dd1D0romSBOfYq_Q7dIh6KEQg0O"
}
});
request.then(function(response){
console.log(response);
},function(error){
console.log(error);
});
Post :
var request = $http({
method : "POST",
url : 'http://api.sandbox.paypal.com/v1/oauth2/token',
data : 'grant_type=client_credentials',
headers : {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/x-www-form-urlencoded',
'Accept-Language': 'en_US',
"Authorization": "Basic QWVRWnpOanM5UGdrQVdyb1VkbjktZ1lhcmNzNUxST2hSN2QyN1VTLTAyb0lXNy1pcmhyMUFkWXhLdkpoY1Q5Y0JoUXlxeHJDZW5MV2JXQjI6RUR4Q3pwbmRkRHBHSVI4SFo2TUR6dzkxYjR6enZndXgwc1hDSFhfU0c5c0pmOHFDNmg4NWd3S3ctTktIbW1ObXNtMFZpT0FQOU84WHREZFc="
}
});
request.then(function(response){
console.log(response);
},function(error){
console.log(error);
});
This API guide in Samsung D forum holds some examples that may help your query regarding Paypal.
Samsung D forum API guide : https://www.samsungdforum.com/TizenGuide/tizen4791/index.html
If you still face issues, You may try posting in the SamsungDForum
SamsungDForum Tizen TV: https://www.samsungdforum.com/SamsungDForum/ForumDashBoard
Thank you.

Error trying to access Paypal API from Parse.com Cloud Code

I'm trying to call Paypay from Parse.com Cloud Code.
I'm getting the following error on Firebug:
{"code":141,"error":"Uncaught Error: Can't form encode an Object"}
I'm using the example straight out of the Paypal example code. My cURL snippet works fine. When I try it with Parse Cloud Code, I get the above error. Here's my Parse Cloud Code:
Parse.Cloud.httpRequest({
url: 'https://svcs.sandbox.paypal.com/AdaptiveAccounts/CreateAccount',
method: 'POST',
headers: { "X-PAYPAL-SECURITY-USERID": "XXXXXXXXX",
"X-PAYPAL-SECURITY-PASSWORD": "XXXXXXXX",
"X-PAYPAL-SECURITY-SIGNATURE": "XXXXXXXXXXXXX",
"X-PAYPAL-REQUEST-DATA-FORMAT": "JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT": "JSON",
"X-PAYPAL-APPLICATION-ID": "APP-NNNNNNNNNNN",
"X-PAYPAL-DEVICE-IPADDRESS": "<my_actual_IP_address>",
"X-PAYPAL-SANDBOX-EMAIL-ADDRESS": "XXXXXXXXXXXXXX"
},
body: { "sandboxEmailAddress":"xyz#me.com",
"accountType":"PERSONAL",
"name": {"firstName":"Lenny","lastName":"Riceman"},
"address":{"line1":"123 Main St", "city":"Austin", "state":"TX", "postalCode":"78759", "countryCode":"US"},
"citizenshipCountryCode":"US",
"contactPhoneNumber":"512-555-5555",
"dateOfBirth":"1968-01-01Z",
"createAccountWebOptions": {"returnUrl":"http://www.example.com/success.html"},
"currencyCode":"USD",
"emailAddress":"lr12345#example.com",
"preferredLanguageCode":"en_US",
"registrationType":"Web",
"requestEnvelope": {"errorLanguage":"en_US"}
},
success: function() {
response.success("Paypal made!");
},
error: function(err) {
response.error(err);
console.error('Request failed with response code ' );
}
Update: May 9, 2014
OK. I don't know if this will help, but here is the exact code that is working for me.
Parse.Cloud.httpRequest({
method: 'POST',
url: 'https://api-3t.paypal.com/nvp -d',
body: {
USER: 'sr1.me.com',
PWD: 'LEgfdgfsdg8',
SIGNATURE: 'gfdgh',
METHOD: 'MassPay',
VERSION: '93',
RECEIVERTYPE: 'EmailAddress',
CURRENCYCODE: 'USD',
EMAILSUBJECT: 'You have a new payment from ',
L_EMAIL0: sellerEmail,
L_AMT0: paypalPmt,
L_NOTE0: paypalNote,
L_UNIQUEID0: bumpSoldTrans
}
Parse.Cloud.define("getUserPayPalToken", function(request, response){
//Setup private varaibles for paypal request to user
var receivers = new Array();
//Setup Receivers for Paypal when payment begins
//Primary Receiver --- Created first array for primary receiver
receivers[0] = new Array();
receivers[0][0] = {'amount':'1.00', 'email':'email-test-1#gmail.com'};
//receivers[0][0] = {'email':request.params.email};
//Secondary Receiver --- Created second array for secondary receiver
receivers[1] = new Array();
receivers[1][0] = {'amount':'2.00', 'email':'test-email#gmail.com'};
var receiverListParams = [{'receiver': receiverParams}];
var receiverParams = JSON.stringify(receiverListParams);
//Set Parse to call PayPal Adaptive Payments
Parse.Cloud.httpRequest({
method:'POST',
url: 'https://svcs.sandbox.paypal.com/AdaptivePayments/Pay',
headers: {
//Setting PayPal request headers
'X-PAYPAL-SECURITY-USERID' : 'xxxxx',
'X-PAYPAL-SECURITY-PASSWORD' : 'xxxxx',
'X-PAYPAL-SECURITY-SIGNATURE' : 'xxxxx',
// Global Sandbox Application ID
'X-PAYPAL-APPLICATION-ID ' : 'APP-80W284485P519543T',
// Input and output formats
'X-PAYPAL-REQUEST-DATA-FORMAT' : 'JSON',
'X-PAYPAL-RESPONSE-DATA-FORMAT' : 'JSON'
},
body:{
'actionType' : 'PAY',
'cancelUrl' : 'http://www.cancel.com',
'currencyCode' : 'USD',
'returnUrl' : 'http://www.return.com',
'requestEnvelope' : {"errorLanguage":"en_US"},
'receiverList' : receiverParams
},
success: function(httpResponse) {
console.log(httpResponse.text);
response.success(httpResponse.text);
},
error: function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
response.error(httpResponse.text);
}
});
});