Author Topic: [GLB + iOS] GETLINECOMMAND$ and Typedeclaration  (Read 552 times)

Offline Hark0

  • Prof. Inline
  • *****
  • Posts: 846
  • Geek Developer
    • View Profile
    • LitioPixel - Desarrollo de videojuegos con GLBasic | Videogame development with GLBasic
Hi, currently I making some test for SHARING FILES on iOS devices.

First, and with help of @Dacarsoft, we declared on info.plist the parameters for define NEW type of file. In this case we declared ERM file format (bin raw file that contains data about map for the game).

Second, on GLB project I made a "trap" routine at start of app for detect Drag&Drop ERM files using GETCOMMANDSLINE$()

On Windows works perfecty... I can drop a ERM file to GLB app icon... the app starts, trap the file dropped, and copy to corresponding folder and run the app normally. The dropped map file are avaliable for play into the app.


Goto iOS...

If I start the app normally... tap on icon... this starts correctly... all done.

BUT

Try for open an ERM file on iOS.... when I receive a file with ERM extension iOS shows option for "Open with ElectricRPG"...

Well, I tap on "Open with..." and the iOS try to open ElectricRPG... open app... and at 1/2 second it closes... I think no load first GLB "runtime"...

AND..... later to "open with"...

If I now open the app normally... the ERM file are correctly imported to /app/Documents/Inbox folder...

(When a new file type declaration are made on XCode, and you try to open.... iOS make a copy of the file to corresponding folder into app... GLB can look this folder for load/save/icloud, etc).


The question are: Why when the iOS try to launch the app are closed? How know what parameters or type of call are using iOS for launch the app?

TIA, Hark0
« Last Edit: 2012-Apr-18 by Hark0 »
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica | Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1592
    • View Profile
    • AMpostata Website
Si tu dices en el info.plist que tu app tiene un folder shared, es simplemente que la carpeta /documents se ve desde iTunes. Así, el usuario, desde el itunes puede meter ficheros en la carpeta /documents del iphone.

Tu app lo que debería hacer al arrancar es ver si hay documentos .erm en su carpeta /documents, leerlos/moverlos/borrarlos y yatta.

Si es que te he entendido, que tu inglés es mu macarrónico...  :nana:

En un hilo por ahí puse enlace a los documentos del iOS donde explica las carpetas del iOS y donde estan y todo ese lío, cambiado desde el iOS 5, pa ke no te rechazen la app.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline spicypixel

  • Dr. Type
  • ****
  • Posts: 499
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
Language mixing arrgghh :-(
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Offline Hark0

  • Prof. Inline
  • *****
  • Posts: 846
  • Geek Developer
    • View Profile
    • LitioPixel - Desarrollo de videojuegos con GLBasic | Videogame development with GLBasic
Si tu dices en el info.plist que tu app tiene un folder shared, es simplemente que la carpeta /documents se ve desde iTunes. Así, el usuario, desde el itunes puede meter ficheros en la carpeta /documents del iphone.

Tu app lo que debería hacer al arrancar es ver si hay documentos .erm en su carpeta /documents, leerlos/moverlos/borrarlos y yatta.

Si es que te he entendido, que tu inglés es mu macarrónico...  :nana:

En un hilo por ahí puse enlace a los documentos del iOS donde explica las carpetas del iOS y donde estan y todo ese lío, cambiado desde el iOS 5, pa ke no te rechazen la app.

(respondo en inglés...)



Yes! The app supports add files with iTunes... and maybe iCloud (declared on mobileprovisionfile and plist).

The objective are too, share filemaps using mail, the idea is send and receive th ERM files defines. Currently the iOS have my own file declared, and offers the option for "Open with". And copy the file attached in email to /app/documents/inbox folder. In GLB I open this file without problem.

The problem are when iOS, after copy the file to inbox folder, TRY to launch the app... closes and returns to iOS.

 O_O
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica | Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *****
  • Posts: 10294
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
My code is:
Code: GLBasic [Select]

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    if (!url) {  return NO; }
 
    NSString *URLString = [url absoluteString];

    __glb_set_cmd_line([URLString UTF8String] );
    return YES;
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
        NSURL *url = [launchOptions objectForKey: UIApplicationLaunchOptionsURLKey];
        if ([url isMemberOfClass: [NSURL class]])
        {
                NSString *URLString = [url absoluteString];
                __glb_set_cmd_line([url UTF8String] );
                printf("Launch with URL:\n    %s\n", [url UTF8String]);
        }

}
 

Any idea what's wrong?

Offline DaCarSoft

  • Mr. Polyvector
  • ***
  • Posts: 134
    • View Profile
Hmmm...

I think that UTF8 encoding may conflict with some "escape" characters contained in an URL.

Perhaps the solution could be this:

Code: GLBasic [Select]

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    if (!url) {  return NO; }
   
    NSString *URLString;
    NSData* tmpURLEncoded = [[NSData alloc] init];
    tmpURLEncoded = [[url absoluteString] dataUsingEncoding:NSWindowsCP1252StringEncoding allowLossyConversion:YES];
    URLString = [[NSString alloc] initWithData:tmpURLEncoded encoding:NSWindowsCP1252StringEncoding];
    tmpURLEncoded = nil;
   
    __glb_set_cmd_line([URLString cStringUsingEncoding:NSWindowsCP1252StringEncoding]);

    return YES;
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
        NSURL *url = [launchOptions objectForKey: UIApplicationLaunchOptionsURLKey];
        if ([url isMemberOfClass: [NSURL class]])
        {
                NSString *URLString;
                NSData* tmpURLEncoded = [[NSData alloc] init];
                tmpURLEncoded = [[url absoluteString] dataUsingEncoding:NSWindowsCP1252StringEncoding allowLossyConversion:YES];
                URLString = [[NSString alloc] initWithData:tmpURLEncoded encoding:NSWindowsCP1252StringEncoding];
                tmpURLEncoded = nil;
       
                __glb_set_cmd_line([URLString cStringUsingEncoding:NSWindowsCP1252StringEncoding]);
                printf("Launch with URL:\n    %s\n", [URLString cStringUsingEncoding:NSWindowsCP1252StringEncoding]);
       
                return YES;        // is a void (!!!) it should appear in some place... ¿?
        }  
   
}


 


As you see, I did a conversion to a temporary NSData using an encoding that should support all the possible contained characters.

After, I convert again to a C string using the same encoding.


How could we test if this could be working now...????


Regards ;)

« Last Edit: 2012-Apr-25 by DaCarSoft »
"Si quieres resultados distintos... no hagas siempre lo mismo" - Albert Einstein.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *****
  • Posts: 10294
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
I will test it and then implement in V11. I'll send you a link to the beta then.
Is it urgent?

Offline DaCarSoft

  • Mr. Polyvector
  • ***
  • Posts: 134
    • View Profile
I suppose that could help a fast solution...

I was helping Hark0 to import maps in his game, near to be finished, I think he wants publish it soon, I suppose he only needs to implement this functionality to finish his App.

If I could test it, I would continue also working on this kind of functions for my own game... But the mine is not near to completion XDDDDD

But, do as you prefer... :)

Thanks for your time in this problem.


Quote
I'll send you a link to the beta then.

* I will be looking at my e-mail or personal messages here, in the forum. TIA.
« Last Edit: 2012-Apr-27 by DaCarSoft »
"Si quieres resultados distintos... no hagas siempre lo mismo" - Albert Einstein.

Offline Hark0

  • Prof. Inline
  • *****
  • Posts: 846
  • Geek Developer
    • View Profile
    • LitioPixel - Desarrollo de videojuegos con GLBasic | Videogame development with GLBasic
I will test it and then implement in V11. I'll send you a link to the beta then.
Is it urgent?

Yor me... YES!

 :)
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica | Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

Offline DaCarSoft

  • Mr. Polyvector
  • ***
  • Posts: 134
    • View Profile
Only for confirmation:

FIXED!

;)
"Si quieres resultados distintos... no hagas siempre lo mismo" - Albert Einstein.

Offline Hark0

  • Prof. Inline
  • *****
  • Posts: 846
  • Geek Developer
    • View Profile
    • LitioPixel - Desarrollo de videojuegos con GLBasic | Videogame development with GLBasic
Re: [GLB + iOS] GETLINECOMMAND$ and Typedeclaration
« Reply #10 on: 2012-May-18 »
Only for confirmation:

FIXED!

;)

 :-*
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica | Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic