I was testing
issue #510 in the google list today and discovered something.
When I was not able to verify the issue for an Android Player (I tested on three different devices and all allowed manual logging into my Facebook Account), I decided to see what happens in iOS.
My iPad 2 (iOS 6.1) is set up with my FaceBook account. So, when I ran the test code using the iOS v1088 Player (self-built), it attempted to log in automagically. And it failed with the following message:
Quote: "AGKPlayer is misconfigured for Facebook login. Press Okay to go back to the application without connecting to Facebook."
At the bottom of the pop-up, it did recognize my correct Facebook name.
So, I decided to see if it was a Player issue and created a Tier 1 app and tested that with the same results.
So, I tried a Tier 2 version, and it crashed on the agk::FacebookLogin() command.
Here is my test code, based on my posted template_ios_xcode4_v1088_al_tweak project:
// Includes, namespace and prototypes
#include "template.h"
using namespace AGK;
app App;
/////////////////////////////////////////
// GLOBALS //////////////////////////////
/////////////////////////////////////////
UINT capture_state = 0;
UINT img,spr;
/////////////////////////////////////////
// PROTOTYPES ///////////////////////////
/////////////////////////////////////////
#ifdef IDE_ANDROID
extern void exit(int);
#endif
int curr_state = 0;
float timeout;
bool logged = false;
/////////////////////////////////////////
// CLASS STATIC ATTRIBUTES //////////////
/////////////////////////////////////////
bool app::did_end = false;
/////////////////////////////////////////
// CLASS IMPLEMENTATION /////////////////
/////////////////////////////////////////
// Begin app, called once at the start
void app::Begin( void )
{
#ifdef IDE_MAC
// use device resolution
agk::SetVirtualResolution(m_DeviceWidth,m_DeviceHeight);
#endif
#if defined(AGKIOS) || defined(IDE_ANDROID)
// use device resolution
agk::SetVirtualResolution(640,960);
// allow all orientations
agk::SetOrientationAllowed(1,1,0,0);
// set to portrait
agk::OrientationChanged(1);
#endif
// start Facebook setup
agk::FacebookSetup("500636119972722");
}
// Main loop, called every frame
void app::Loop ( void )
{
// check for ended
if (app::did_end) return;
// check for closing
if (agk::GetPointerPressed())
{
// call method to close up
closeThisApp();
// make sure to skip out (otherwise the Sync() call fails)
return;
}
// process state
switch(curr_state)
{
case 0:
// start login
agk::FacebookLogin();
curr_state = 1;
timeout = agk::Timer() + 5.0f;
break;
case 1:
// check for logging in
agk::Print("Logging In");
if (agk::GetFacebookLoggedIn()||(agk::Timer()>timeout))
{
curr_state = 2;
logged = (agk::GetFacebookLoggedIn()==1?true:false);
}
break;
case 2:
// do app activities
if (logged) agk::Print("Connected to Facebook!");
else agk::Print("Could not log in to Facebook!");
agk::Print("");
agk::Print("Touch anywhere to exit");
break;
}
// update the display
agk::Sync();
}
// End app, called once at the end
void app::End ( void )
{
}
void app::closeThisApp()
{
// indicate done
app::did_end = true;
// completely exit the app
#ifdef AGKWINDOWS
PostQuitMessage(0);
#endif
#ifdef AGKIOS
// forcing a quit in iOS is against recommended guidelines - use HOME button
// the exit button is disabled on AGKIOS builds
// but if you want to do so, this is the code
agk::MasterReset();
exit(1);
#endif
#ifdef IDE_ANDROID
// similar to iOS, an exit button should not be done
// but if you want to do so, this is the code
agk::MasterReset();
exit(0);
#endif
#ifdef IDE_MAC
glfwCloseWindow();
#endif
}
The header file looks like this:
#ifndef _H_APP
#define _H_APP
// Link to AGK libraries
#include "agk.h"
/////////////////////////////////////////
// CLASS DEFINITION /////////////////////
/////////////////////////////////////////
class app
{
public:
// static attributes
static bool did_end;
public:
// main vars
#ifdef IDE_MAC
unsigned int m_DeviceWidth;
unsigned int m_DeviceHeight;
#endif
public:
// constructor
app() {memset(this, 0, sizeof(app));}
// main app functions
void Begin( void );
void Loop( void );
void End( void );
private:
void closeThisApp();
};
extern app App;
#endif
// Allow us to use the LoadImage function name
#ifdef LoadImage
#undef LoadImage
#endif
EDIT: The crash (when run from Xcode) ends up with this display in the center panel:
libobjc.A.dylib`_cache_getImp:
0x3a1e6560: lsr.w r9, r1, #2
>>0x3a1e6564: ldr r3, [r0, #8] Thread 1: EXC_BAD_ACCESS (code=1, address=0x60000008)
0x3a1e6566: add.w r3, r3, #8
0x3a1e656a: ldr r12, [r3, #-8]
0x3a1e656e: and.w r9, r9, r12
0x3a1e6572: ldr.w r0, [r3, r9, lsl #2]
0x3a1e6576: teq.w r0, #0
0x3a1e657a: add.w r9, r9, #1
0x3a1e657e: beq 0x3a1e6592 ; _cache_getImp + 50
0x3a1e6580: ldr.w r12, [r0]
0x3a1e6584: teq.w r1, r12
0x3a1e6588: bne 0x3a1e656a ; _cache_getImp + 10
0x3a1e658a: ldr.w r12, [r0, #8]
0x3a1e658e: mov r0, r12
0x3a1e6590: bx lr
0x3a1e6592: mov.w r0, #0
0x3a1e6596: bx lr
0x3a1e6598: nop
0x3a1e659a: nop
0x3a1e659c: nop
0x3a1e659e: nop
And Thread 1 in the left panel shows:
com.apple.main-thread
0 cache_getImp (this is highlighted and has a gear next to it)
13 UIApplicationMain
14 main
15 start
Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master