Facebook UI dialog callback not fired - trigger.io

I am using forge.facebook.ui to send app requests to users. The dialogue opens as expected and selects the correct user to send the invite to. However it appears the callbacks (success or error) are never fired when the user clicks 'send'. Code example below:
forge.facebook.ui(
{
title: 'Invite your Friend,
method: 'apprequests',
to: 1234567,
message: 'Sign up'
},
function(response) {
forge.logging.info(response); // Never Called
},
function (e) {
forge.logging.info('facebook failed: ' + JSON.stringify(e)); // Never Called
}
);
In the past this was working correctly.

This did turn out to be a bug introduced in a recent Forge version, I've just committed a fix which will be in the next Forge platform version, which we should be deploying tomorrow (06/11/2012).

Related

Unable to log in Dailymotion user using JS SDK

I have a React app from which I want to upload videos to the account of the logged in user. I have successfully done this retrieving tokens manually and calling the API but can't find a way to log in using the JS SDK in my React app.
I present the user with a button for log in:
e.preventDefault()
window.DM.login(
function (response) {
if (response.session) {
// user successfully logged in
console.log(response)
} else {
// user cancelled login
console.log(response)
}
},
{
client_id: my_id,
scope: "read write",
response_type: "code"
}
)
}
The login popup appears, I log in and get sent to the callback url. However, refreshing the original site, or the callback popup, still shows as no session and without login. I check with:
status === 'ready' &&
window.DM.getLoginStatus(function (response) {
if (response.session) {
// logged in and connected user, someone you know
console.log(response)
} else {
// no user session available, someone you dont know
console.log(response)
}
})
})
and I always get { status: "unknown", session: null }
Loading the SDK is handled with a hook const status = useScript('https://api.dmcdn.net/all.js')
Do I need to handle something manually from the callback page? Isn't the SDK supposed to handle it in the background? I would appreciate some insights on what I might be doing wrong.
Thanks.
As always, I spent hours trying to find a solution and, as soon as I post, I find it:
Client_id and response_type must not be passed in DM.login.
Instead, you have to pass the API key in DM.Init, like so:
useEffect(() => {
status === 'ready' &&
window.DM.init({
apiKey: '123456789',
status: true, // check login status
cookie: true // enable cookies to allow the server to access the session
});
})
This brings up the popup and after inputting the credentials the SDK correctly detects the session, closing the popup and authing the user.

Periodic sync not fired in service worker

I'm trying to use background periodic sync for my website. I'm using localhost and registering the periodicsync event at 1*1000 ms, but that doesn't fire at all.
I had a look at this demo, but even if I install the website as an app, it won't fire at all.
Using chrome 87.0.4280.66.
It works however if I manually trigger the periodic sync event from Application developer window.
The periodicsync event will only register correctly when the app is installed as a PWA in a 'most' webkit based browsers only
https://developer.mozilla.org/en-US/docs/Web/API/Web_Periodic_Background_Synchronization_API
The conditions as to whe this will actually fire is unclear and is dependent on some wooly factors such as the users engagement with the website.
That is why the perameter that can be set when registering for the periodic sync is minInterval
This block will help you to register for it successfully, I am, unfortunatly unclear on what the 'real world' scenarios in which the peridic sync will fire:
const status = await navigator.permissions.query({
// #ts-ignore
name: 'periodic-background-sync',
});
if (status.state === 'granted') {
navigator.serviceWorker.ready.then(async (sw: any) => {
await sw.periodicSync.register('periodicsync', {
minInterval: 1000,
});
})
.catch(error => {
console.error('[BackgroundSync] Error: ' + JSON.stringify(error, null, 2));
});
}
else {
console.error('[BackgroundSync] Does not have permission');
}
}

Braintree client-token validation error

I am using braintree Drop-in UI with angularjs(frontend) and rails(Backend). I am creating a clientToken and sending it to braintree setup.
The client-token method,
#client_token = Braintree::ClientToken.generate(customer_id: current_user.braintree_customer_id,options: {
verify_card: true,
fail_on_duplicate_payment_method: true
})
So as you can see, I have taken 'fail_on_duplicate_payment_method' option. And trying to add the same payment method again.
Then, with that validation I am getting an error on the dropin saying "There was an error processing your request", but it is not coming to the error callback.
This is the setup, which is fine,
braintree.setup(vm.clientToken, 'dropin', {
container: 'dropin-container',
onPaymentMethodReceived: function(data)
{
alert('came recieved')
// console.log($scope.paymentForm)
vm.submit($scope.paymentForm, data.nonce)
},
onReady: function () {
vm.disablePay = false;
},
onError: function(type, message) {
alert('came error')
vm.serverError = message;
}
});
Here is the Image of the error,
The error in the network is,
callback_jsona7f3c885267b4f49aa13fbf01cecdb60({"error":{"message":"Credit card is invalid"},<br>"fieldErrors":[{"field":"creditCard","fieldErrors":[{"field":"number","code":"81724","message":"Duplicate card exists in the vault"}]}],"status":422})
I want to fetch this error into my view. I searched many links, but didn't get the answer I needed. Any help is appreciable.
Thankyou in Advance.
Full Disclosure: I work as a developer for Braintree
The onError callback is only triggered by client side errors and this is actually a server side error; however, the team is aware of this need and is working on a solution that will be available in a future release.

Facebook plugin for phonegap ios application - share on the wall

I am trying to share from my phonegap ios application. I use this code to post to my facebook wall
var facebookConnectPluginPostToTheWall = function () {
var options =
{
method: "feed",
name: "Shared via my cool app",
message: "This is a post shared from my app. I have earned 300xps."
};
facebookConnectPlugin.showDialog(options,
function (response) {
alert(JSON.stringify(response))
});
};
And it shares the post to the facebook, but I can't make it work with these preset values for message, title etc. It just shares the text I enter in the popup shown after calling this function. I hope someone can help with this.
The feed dialog does not accept any prefilled messsage - but prefilling is not allowed anyway, the message always must be 100% user generated.
If you want to post without a dialog, you have to authorize the user with publish_actions and use the feed API: https://developers.facebook.com/docs/graph-api/reference/v2.2/user/feed
But again, prefilling the message is not allowed. Read the platform policy for more information: https://developers.facebook.com/policy/

Send email when a new user is created via iOS app using Parse.com

I want to send an email each time a new user is created in my iOS app. I'm using Parse.com as my back-end and have been reading about Cloud Code. I'm assuming I can use this to monitor object creation and kick off a function to send an email when a specific object (user) is created in the database. I know I can create a function within CloudCode then call this function in my iOS app once a user is created, but I'd like to be able to do this same thing without submitting an update to the App Store. Is there a way to accomplish this without submitting a new binary?
You can add an afterSave Cloud Code function then you don't need to change your app - the new code will simply be invoked every time your user object is saved. This example uses SendGrid, so you would need a SendGrid account
Parse.Cloud.afterSave(Parse.User, function(request) {
if(!(request.object.existed())){
var SendGrid = require("sendgrid");
SendGrid.initialize("username", "password");
SendGrid.sendEmail({
to: "email#example.com",
from: "SendGrid#CloudCode.com",
subject: "Hello from Cloud Code!",
text: "Using Parse and SendGrid is great!"
}, {
success: function(httpResponse) {
console.log(httpResponse);
},
error: function(httpResponse) {
console.error(httpResponse);
}
});
}
});

Resources