Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Parse iOS SDK integration using BhWax — Gideros Forum

Parse iOS SDK integration using BhWax

krisiskrisis Member
edited March 2013 in Plugins
We have integrated the Parse iOS SDK with the Gideros Player and created a module using BhWax to interact with Parse (http://www.parse.com/).

For those of you that haven’t used Parse before, it is basically a “backend-as-a-service” provider allowing you to store and query data from their cloud. They also have additional features like social integration, push notifications, and the ability to run custom code.

This initial integration includes a fully customizable login and signup flow using Parse Social, allowing native Facebook and Twitter auth. It also includes some basic code for pushing data to the Parse cloud, which will be further expanded upon going forward. We also plan on adding the push notification integration too. The Facebook iOS SDK is baked into the Parse SDK so you also get that integration for free.

We have made the code freely available on GitHub - https://github.com/pushpoke/gideros-parse

You can read about the integration and view a video of it in action on our blog: http://pushpoke.com/2013/03/parse-integration-with-gideros-using-bhwax/.

Would love to hear any feedback from anyone that uses it, or any comments/questions about the integration.

Cheers!
[ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
+1 -1 (+4 / -0 )Share on Facebook

Comments

  • I would also like to thank @bowerandy for all his help with my questions on BhWax!

    This module uses BhWax with UIViewController, UIImage, UIAlertView, delegates and block handlers.
    [ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
  • @krisis
    thank you for sharing.
    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps
  • unlyingunlying Guru
    edited June 2013
    Great! Is it possible to use Parse with Android Gideros projects?
  • krisiskrisis Member
    They have an Android SDK and a REST API, however I just used the iOS SDK due to some built-in functionality it has like query caching, install tracking and push notif handling.
    [ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
  • Thank you so much Krisis for this module :)

    The problem I'm having is after I have built the Gideros iOS Player and try the gideros-parse.gproj, I get the following error in Gideros:
    Uploading finished.
    Creating a new Anonymous PFUser
    ./ParseLib.lua:94: attempt to call method 'asVoidDyadicBlockBO' (a nil value)
    stack traceback:
    	./ParseLib.lua:94: in function 'init'
    	[string "property.lua"]:52: in function '__new'
    	[string "property.lua"]:59: in function 'new'
    	main.lua:56: in main chunk
    What could be the problem?
  • krisiskrisis Member
    You'll need to update your BhWax.mm to the latest from the repo. The 'asVoid*' functions are wax's way of handling Obj-C blocks, and depending on the object types and number of params in the Obj-C functions you're using, you may need to add new ones. asVoidDyadicBlockBO was to indicate two params, Bool + Object (BO).

    My BhWax.mm includes:
    <a href="https://forum.gideros.rocks/profile/interface" rel="nofollow">@interface</a> WaxFunction (Blocks)
    - (void (^)())asVoidNiladicBlock;
    - (void (^)( NSObject *))asVoidMonadicBlock;
    - (void (^)( NSObject *, NSObject *))asVoidDyadicBlock;
    - (void (^)( BOOL, NSObject *))asVoidDyadicBlockBO;
    - (void (^)( NSObject *, NSObject *, NSObject*))asVoidTriadicBlock;
    <a href="https://forum.gideros.rocks/profile/end" rel="nofollow">@end</a>
     
    -(void (^)())asVoidNiladicBlock {
        return [^() {
            lua_State *L = wax_currentLuaState();
            wax_fromInstance(L, self);
            lua_call(L, 0, 0);
        } copy];
    }
     
    -(void (^)(NSObject *p))asVoidMonadicBlock {
        return [^(NSObject *param) {
            lua_State *L = wax_currentLuaState();
            wax_fromInstance(L, self);
            wax_fromInstance(L, param);
            lua_call(L, 1, 0);
        } copy];
    }
     
    -(void (^)(NSObject *p1, NSObject * p2))asVoidDyadicBlock {
        return [^(NSObject *param1, NSObject *param2) {
            lua_State *L = wax_currentLuaState();
            wax_fromInstance(L, self);
            wax_fromInstance(L, param1);
            wax_fromInstance(L, param2);
            lua_call(L, 2, 0);
        } copy];
    }
     
    -(void (^)(BOOL p1, NSObject * p2))asVoidDyadicBlockBO {
        return [^(BOOL param1, NSObject *param2) {
            lua_State *L = wax_currentLuaState();
            wax_fromInstance(L, self);
            lua_pushboolean(L, param1);
            wax_fromInstance(L, param2);
            lua_call(L, 2, 0);
        } copy];
    }
     
    -(void (^)(NSObject *p1, NSObject * p2, NSObject *p3))asVoidTriadicBlock {
        return [^(NSObject *param1, NSObject *param2, NSObject *param3) {
            lua_State *L = wax_currentLuaState();
            wax_fromInstance(L, self);
            wax_fromInstance(L, param1);
            wax_fromInstance(L, param2);
            wax_fromInstance(L, param3);
            lua_call(L, 3, 0);
        } copy];
    }
    <a href="https://forum.gideros.rocks/profile/end" rel="nofollow">@end</a>
    [ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
  • Thanks Krisis, somehow I missed that step. I've updated my BhWax.mm file but now I'm getting:
    Uploading finished.
    Creating a new Anonymous PFUser
    ./ParseLib.lua:108: Error invoking method 'initializeWithApplicationId:' on 'PFFacebookUtils' because You must initialize PFFacebookUtils with a call to +initializeFacebook.
    stack traceback:
    	./ParseLib.lua:108: in function 'init'
    	[string "property.lua"]:52: in function '__new'
    	[string "property.lua"]:59: in function 'new'
    	main.lua:56: in main chunk
    Thanks again, and sorry for bothering you.
  • comontescomontes Member
    edited June 2013
    Maybe the issue is that I'm using Facebook iOS SDK version 3.5.5 (last one)? Which version do you use?

    just found this: http://blog.parse.com/2013/03/11/facebooks-latest-ios-sdk-update-and-what-it-means-for-you/
  • Yeah, this fixed it :

    Change your call to [PFFacebookUtils initializeWithApplicationId:] to [PFFacebookUtils initializeFacebook]. Note that you’ll need to make sure that your Facebook Application ID was set in your application’s plist file under the key FacebookAppID as described in section 5 of Facebook’s getting started guide.

    Not sure how it should be:

    PFFacebookUtils:initializeFacebook(facebookAppId)
    or PFFacebookUtils:initializeFacebook()

    ??




  • krisiskrisis Member
    Yeh, my lib was using the previous Parse SDK which had FB SDK built in to it.

    The second method should work assuming you've setup the FB plist stuff properly with your FB App ID (according to FB SDK instructions).

    PFFacebookUtils:initializeFacebook()
    [ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
  • It works with PFFacebookUtils:initializeFacebook(), goes into Facebook and asks for permission, but when it gets back to the app it gets stuck in loading now. I'm gonna keep trying :) thanks Krisis
  • krisiskrisis Member
    That could be a Facebook App config issue. I think the fix is in the FB app settings, under Settings > Permissions you need to set Auth Token Parameter to URI Fragment.
    [ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
  • comontescomontes Member
    edited June 2013
    Thanks, that was needed, but also I had to change my AppDelegate.m, I have at the beggining (search "

    #import "AppDelegate.h"
    #import "ViewController.h"
    #import <---- this is from before


    #import <AVFoundation/AVFoundation.h>

    #include "giderosapi.h"

    @implementation AppDelegate

    @synthesize window;
    @synthesize viewController;

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {



    CGRect bounds = [[UIScreen mainScreen] bounds];

    self.window = [[[UIWindow alloc] initWithFrame:bounds] autorelease];

    self.viewController = [[[ViewController alloc] init] autorelease];
    self.viewController.wantsFullScreenLayout = YES;

    [self.viewController view];

    currentAudioSessionCategory = AVAudioSessionCategorySoloAmbient;
    [[AVAudioSession sharedInstance] setCategory:currentAudioSessionCategory error:nil];




    [Parse setApplicationId:@blahblahblah
    clientKey:@blahblahblah];
    [PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
    [PFFacebookUtils initializeFacebook]; <---- this is NEW




    gdr_initialize(self.viewController.glView, bounds.size.width, bounds.size.height, true);

    if ([[[UIDevice currentDevice] systemVersion] compare:@6.0 options:NSNumericSearch] != NSOrderedAscending)
    {
    [self.window setRootViewController:self.viewController];
    }
    else
    {
    [self.window addSubview:self.viewController.view];
    }

    gdr_drawFirstFrame();

    [self.window makeKeyAndVisible];

    return YES;
    }



    #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_2
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
    {
    gdr_handleOpenUrl(url);

    return [PFFacebookUtils handleOpenURL:url];

    Seems to work, but I have NO IDEA of what I'm doing :S . I have no Objective-C or Xcode experience.
Sign In or Register to comment.