[GLB + iOS] GETLINECOMMAND$ and Typedeclaration

Previous topic - Next topic

Hark0

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
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

ampos

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

spicypixel

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.

Hark0

Quote from: ampos on 2012-Apr-18
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

Kitty Hello

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?

DaCarSoft

#5
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 ;)

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

Kitty Hello

I will test it and then implement in V11. I'll send you a link to the beta then.
Is it urgent?

DaCarSoft

#7
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.


QuoteI'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.
"Si quieres resultados distintos... no hagas siempre lo mismo" - Albert Einstein.

Hark0

Quote from: Kitty Hello on 2012-Apr-26
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

DaCarSoft

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

Hark0

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