Open In for iOS

This is the place to get technical support and discuss all things to do with MergEXT

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, monte

Post Reply
dhurtt
Posts: 42
Joined: Sat Nov 09, 2013 7:37 pm
Location: Huachuca City, AZ

Open In for iOS

Post by dhurtt » Wed Jan 15, 2014 3:45 am

I looked at mergExt's mergDoc and it appears that it can present a popover for opening a file in another app, but I was wondering if mergExt (or anyone else's product) has an external that allows your app to register for file types that it can open, such as discussed on this page from Apple. I would still need to figure out how to get such a document onto the device – probably email ...

dhurtt
Posts: 42
Joined: Sat Nov 09, 2013 7:37 pm
Location: Huachuca City, AZ

Re: Open In for iOS

Post by dhurtt » Wed Jan 15, 2014 3:51 am

Hmmm, the more I dig the more it looks like I need to mess with the plist.info, but this Apple document implies that your app has to handle a special event when asked to open the file. So maybe the question should be: has anyone done this sort of thing, and is an external required?

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Open In for iOS

Post by Nakia » Wed Jan 15, 2014 4:30 am

I have one of my Apps doing this if I understand what you are asking.
If the users is sent a file type via mail, my App shows up in the list of Apps that will support/use it. I took it a little further and extended my needs to a custom file type.

if this is what you mean let me know and I can share how I got it to work
(BTW, didn't need an external from memory)

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: Open In for iOS

Post by monte » Wed Jan 15, 2014 10:27 pm

Kia is right. You don't need an external for this.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

dhurtt
Posts: 42
Joined: Sat Nov 09, 2013 7:37 pm
Location: Huachuca City, AZ

Re: Open In for iOS

Post by dhurtt » Thu Jan 16, 2014 5:01 am

Nakia wrote:if this is what you mean let me know and I can share how I got it to work
(BTW, didn't need an external from memory)
Cool. Yes, that is exactly what I am looking for. I was hoping to email a game file to another iPad and when they tapped the file it would present a "Open In" [my app] menu item.

If you want to take this offline, or out of this forum, let me know. I am at dale dot hurtt at specitllc dot com.

Thanks in advance,

Dale

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Open In for iOS

Post by Nakia » Thu Jan 16, 2014 5:57 am

Okay,

Firstly this is how I got it to work. I am not saying its correct or the best but it works for me!

Step 1:
You need to edit your 'Settings.plist' file and add the following. FYI you find this by Right clicking on your LC Program in Apps then exploring to
"Contents/Runtime/iOS/Device/"

Code: Select all

<key>CFBundleDocumentTypes</key>
	<array>
    	<dict>
        <key>CFBundleTypeIconFiles</key>
        <array>
            <string>Icon.png</string> -->This is the name of the PNG Mail will show in the list of Applications that can process the File Type
        </array>
        <key>CFBundleTypeName</key>
        <string>Cool Game File</string> --> This is the description of your custom file type (Example, 'Cool Game File')
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.companyname.appname.extension</string> --> This is partially taken from detail you set in LC Standalone App Settings (Example, 'com.blueducksoftware.coolgame.cgf')
        </array>
    	</dict>
</array>
<key>UTExportedTypeDeclarations</key>
	<array>
    	<dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.plain-text</string> --> This describes to iOS what Type the file conforms to, if it's just text this should work.
            <string>public.text</string> --> This describes to iOS what Type the file conforms to, if it's just text this should work.
        </array>
        <key>UTTypeDescription</key>
        <string>Cool Game File</string>  --> This is the description of your custom file type (Example, 'Cool Game File')
        <key>UTTypeIdentifier</key>
                    <string>com.companyname.appname.extension</string> --> This is partially taken from detail you set in LC Standalone App Settings (Example, 'com.blueducksoftware.coolgame.cgf')
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <string>cgf</string> --> This is your custom file extension (Example, 'cgf')
        </dict>
    	</dict>
</array>

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Open In for iOS

Post by Nakia » Thu Jan 16, 2014 6:08 am

Step 2:

All that is required to process this after your App is opened from one of these file is the 'URLWakeUp' command.
This will pass the path to the file (the one you clicked on in Mail App) from which you can then place into your Apps cache directory and do with it what you will.

Note:
1.The path URLWakeUp passes is fully justified so you have to pull out only the portion that you need.
2. When you open the file it creates an 'Inbox' folder in your App directory and you grab the file from there.

This is how I did mine
(Could be improved upon)

Code: Select all

on urlWakeUp pURL
   ## Ability for the user to import Hours templates, will accept individual .wtt files which can be emailed to device
   ## then the user can open the file into WesTec for importing.
   if the environment = "mobile" then
      mobileBusyIndicatorStart "square", "Importing"
      -- Retrieve the filename as passed to the Application
      set the itemdel to "/"
      put item (the number of items in pURL) of pURL into tFileName
      set the itemdel to comma
      -- Check to see the TimesheetTemplates folder exists, create if false
      put specialFolderPath("Documents") & "/TimesheetTemplates/" into tFolderExists
      if there is not a folder tFolderExists then
         create folder specialFolderPath("Documents") & "/TimesheetTemplates/"
      end if
      -- Here we grab the contents of the wtt file
      if tFileName contains ".wtt" then
         put URL ("file:" & specialFolderPath("Documents")&slash&"Inbox"&slash&tFileName) into tFileContents
     end if
on urlWakeUp pURL

Now you can do what you like with your file contents

dhurtt
Posts: 42
Joined: Sat Nov 09, 2013 7:37 pm
Location: Huachuca City, AZ

Re: Open In for iOS

Post by dhurtt » Thu Jan 16, 2014 7:04 am

This is great. I will have to try it out. One question though: where do I put the "icon.png" file? Or do I simply add it as a file in the Standalone Settings and the build puts it in the proper path?

Thanks again.

Dale

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Open In for iOS

Post by Nakia » Thu Jan 16, 2014 7:31 am

I just used the copy files pane as you suggested!

I'm not even certain it uses it to be honest as I didn't have it there once and it still worked ???

Post Reply

Return to “MergEXT”