How to use FB Javascript SDK Event Subscribe - facebook-javascript-sdk

I've recently implemented FB Javascript SDK for a mobile web app and am playing with their event subscription code:
FB.Event.subscribe('auth.statusChange', handleStatusChange);
I notice that handleStatusChange is called when I log in into facebook through my app. However, if I open another browser tab, go to facebook.com and log out the function isn't called.
I was expecting it to be called. Am I wrong? I thought the point of this function was to monitor changes that were not necessarily within the purview of my app.
Thanks!

auth.authResponseChange - fired when the authResponse changes
https://developers.facebook.com/docs/reference/javascript/FB.getAuthResponse/
This would be when a users add or removes a permission, in our flows we are supposed to provide away for a users to remove each permission and authResponse allows us to monitor.

Related

How to configure Android Push Notifications (GCM) in Appcelerator Titanium Dashboard?

I've tried to following the instructions
Configuring push services for Android devices
However, the steps mention 'Click Push Notifications on the left-side navigation' but they don't exist...
Once you've created a Google API project with GCM enabled, you need to update your application's settings page in Dashboard with the API key and sender ID you generated.
To configure Arrow for push notifications using Dashboard:
Open Dashboard and select your application from the Apps drop-down menu.
Click Push Notifications on the left-side navigation <-- MISSING.
Select the Android Push tab.
Enter the server key in the GCM API Key field and the GCM sender ID in the GCM Sender ID field.
Here's a screenshot to show what's listed...
If I look under Arrow (where I suspect it might be expecting to be listed) that's empty (I'm not using Arrow - I thought it was an alternative UI using declarative XML)...
I've checked the subscription that I'm on (Indie) and it shows that I should have the ability to send up to 1 million push notifications for free..
Does anyone know how I can associate the Appcelerator Titanium project to the GCM server key??
Also, when I looked in Googles developer console, my application (which is live on their app store) wasn't listed, so I've created a new application called 'Gcm'. The Appcelerator Titanium seemed to confirm that I needed to 'create' the application, I was just too worried to call it the same name as the live application. How does the 'Google Developer Console' Application relate to the 'Google Play' application?! - if at all?
UPDATE
I've just discovered in TiApp.xml that I can enable some 'Cloud' settings and this has unlocked the 'Push' menu - so I think all is good now, could someone confirm that this is the right thing to do and answer my related question about Google play applications v google developer console applications?
Update 2
I started to get this error
[ERROR] : GooglePlayServicesUtil: The Google Play services resources
were not found. Check your project configuration to ensure that the
resources are included.
[INFO] : CloudPush.retrieveDeviceToken error: INVALID_SENDER
I'm simply calling this to try and register for Android push notifications ...
CloudPush.retrieveDeviceToken({
success : function(e) {
console.info("CloudPush.retrieveDeviceToken success");
},
error : function(e) {
console.info("CloudPush.retrieveDeviceToken error:"+e.error);
}
});
I have tried with and without the ti.cloud module (I think it got added when I clicked the 'Enable Services' button which meant that I could see the 'Push Notifications' tab, but it seems to still be listed whether the ti.cloud module is elected or not)..
Before..
Q - How to stop the Google Play error and retrieve the device token (oddly I was getting the token before enable services.
Q - Is ti.cloud used to receive the push notification, or is ti.cloudpush sufficient for this?
Thanks for the detailed question :) Let me go into some of the things you mention and clarify what I can.
If I look under Arrow (where I suspect it might be expecting to be listed) that's empty
As you later found out you have to enable platform services for your app which will create an ArrowDB app with the same name as your app. This app will have the Push Notifications in the sidebar to configure. I've updated the guide's wordings to make clear we mean the ArrowDB app, not the Titanium app.
(I'm not using Arrow - I thought it was an alternative UI using declarative XML)...
Don't confuse Arrow with Alloy - which is the MVC framework for Titanium which indeed uses XML.
How does the 'Google Developer Console' Application relate to the 'Google Play' application?! - if at all?
It doesn't. You can even have multiple apps share the same GCM sender.
[ERROR] : GooglePlayServicesUtil: The Google Play services resources were not found.
What did you use to test? A Genymotion emulator without Google Apps installed perhaps? You'll need that.
Is ti.cloud used to receive the push notification, or is ti.cloudpush sufficient for this?
ti.cloud is the module to communicate with ArrowDB, subscribe to channels etcetera. On Android you need ti.cloudpush (or as #Shawn mentioned another module) to retrieve the device token where on iOS you can use a Ti. API for that. Follow this guide for all steps.
You can ignore the Google Play Service error, but it seems your GCM Sender ID and/or API Key is wrong. Read through the tutorial and make sure you put down the right ones.
If you are using Appcelerator Cloud Service to send push notifications, you need ti.cloud to register the devices.
To get the device token and to receive push notifications, you use ti.cloudpush. There are other modules that you can use instead of ti.cloudpush.

Real time checkins stop working after app is uninstalled and reinstalled

We are working on an iPhone app that uses Facebook's realtime checkin data. We noticed that if we uninstall the app and reinstall the app, we see one of the two issues:
Facebook realtime updates stop working for some users. i,e, our servers receive no checkin notifications from Facebook when user checkis-in. It all works well before user uninstalls the app.
Facebook sends realtime updates, but when we try to retrieve checkin data, we get empty result set:
Query: (using the appropriate auth_token)
/me/checkins
Response:
{
"data": [
]
}
Data is empty when we test from debug tool as well.
More info:
We use a "Deauthorize Callback URL", which points to a specific URL on our server, and we do return a success back to Facebook upon invocation of that URL.
User is prompted for the appropriate permissions upon reinstalling the app. (Permissions used: publish_actions).
We did verify that the app is allowed to use Facebook (iPhone->Settings->Facebook).
When user logs into Facebook on a web browser and selects the app from "Your Apps" section, we do see proper permissions.
We did verify the permissions from Open graph debug took as well. They look alright.
Any idea what might be going on here?
Regarding #2, contrary to what Facebook says in https://developers.facebook.com/docs/reference/api/checkin/, the 'user_checkins' permission is needed. If you use the permission 'user_status' the checkin data array is empty.
This smells like a facebook bug.

Running hangout app from API console/Sandbox, unable to invite other (test) participants

Hi all: I'm trying to test a hangout app, running from the API Console link/in the Sandbox.
Machines are
- Mac OS X,
- latest normal Chrome.
Both users are
- Google Apps users,
- added to API Team for hangout project,
- able to see the App Engine application for static files etc.
User one is API project owner, user two can view project.
As user one, I click the API Console/Sandbox link to start.
The plugin starts, and the app starts right away.
I click on the App icon at left to hide the app.
I click on the blue Invite People button to invite user two.
The app frame goes blank, no way to invite user two.
In user one's console, there's only one error, prior to app startup:
Failed to load resource: the server responded with a status of 404 (Not Found)
https://hangoutsapi.talkgadget.google.com/talkgadget/channel
Starting with user two, I get two errors--first the following, followed by the above error, followed by app startup:
Uncaught TypeError: Cannot call method 'isLoaded' of undefined
:87
The stacktrace of this error goes
0d.be :87
init: (program):1
onload :1
0d.load :1
Gg :120
window.jstiming.js :124
(anonymous function) :371
... no file names, just line numbers.
I have not gone through the OAuth client ID configuration yet. Is this needed for Sandbox work between two users (as opposed to individually)?
I need a way to get these two users into the same hangout. Eventually I can do this through server-sent URLs (I believe) but for yesterday I need a quick 'n' dirty method.
Many thanks for any insight.
Kirk.
Instead of trying to use Invite, you may want to send the URL of the sandboxed hangout to the other person.
You may also want to skip the sandbox altogether and just publish the code and work with the "public" version.

How to launch Facebook with Button

Hey friends
I created a button on my app called: "Find us on Facebook". Right now I ran into a situation where I need the button to launch the Facebook application. I could really use some help such as launching the facebook application, detecting if there is a facebook application, and all the sorts of stuff like that, thanks
Some googling shows that the facebook app apparently registers to receive urls with the fb:// scheme. So you can construct a fb:// url (like, say fb://notes or something) and then ask the UIApplication object if it can open the URL. If it says that it can, then open it.
there is a tutorial and sample app at https://github.com/facebook/facebook-ios-sdk
Basically you need to try to call fb://profile/yourpageid to load the FB app on your page.
The sample app shows you how to do this and fall back to loading in Safari if the app is not installed on the device.

On a Mac how to determine a user logout is occuring

I am very new to the Mac platform and Objective-C in general and in my application I would like to know how to determine that a user is logging out and perform some actions prior to this. Any info or pointers for this?
The official way to put the hook at logging in / logging out is described in these Apple documents Customizing Login and Logout and Tech Note 2228. But I'm afraid that the log-out hook was no longer directly supported.
So, the second best way is to run a headless Cocoa app, and receive a notification from the system using NSWorkspace, see the document and the list of available notifications.
To make a headless Cocoa app, you need to set an entry in its Info.plist called LSUIElement, see here. By setting LSUIElement to be yes, the app don't appear in the dock, but perform various operation in the background.
Take a look at Receiving Workspace Notifications in this Workspace Services document.
NSWorkspaceWillPowerOffNotification
Posted when the user has requested a
logout or that the machine be powered
off.