omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Issues opening textastic to view source

    Pythonista
    5
    12
    7761
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • miwagner1
      miwagner1 last edited by

      Am I missing something here? It is not opening the textastic app.

      # coding: utf-8
      
      import appex
      import webbrowser
      from urlparse import urlsplit
      
      def main():
      	if not appex.is_running_extension():
      		print 'This script is intended to be run from the sharing extension.'
      		return
      	url = appex.get_url()
      	if not url:
      		print 'No input URL found.'
      		return
      	url = urlsplit(url)
      	url = 'textastic://' + url.netloc + url.path + url.query + url.fragment
      	print url
      	webbrowser.open(url)
      	
      if __name__ == '__main__':
      	main()
      
      marcus67 1 Reply Last reply Reply Quote 0
      • marcus67
        marcus67 @miwagner1 last edited by

        @miwagner1 Could you post the typical output of the print statement, please?

        1 Reply Last reply Reply Quote 0
        • JonB
          JonB last edited by

          share app extensions cannot launch other apps. Only Today Widgets. Its an Apple thing.

          1 Reply Last reply Reply Quote 1
          • miwagner1
            miwagner1 last edited by

            Marcus67 the typical output looks like

            textastic://forum.omz-software.com/topic/2616/can-pythonista-push-itself-into-the-foreground
            

            Well dam if an extension can't open an app, I'm going to have to get fancy for viewing source code.

            1 Reply Last reply Reply Quote 1
            • miwagner1
              miwagner1 last edited by

              Ok so workflow can open other apps from the app extension. The user just had to confirm it. So how would I do this from the pythonista extension?

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by

                I think workflow has a today extension? so maybe that's it?
                Alternatively, you could post a notification. If you set pythonista notifications to alerts instead of banners, then younwould effectively get prompted to open the app.

                1 Reply Last reply Reply Quote 0
                • JonB
                  JonB last edited by

                  scratch that... this does work

                  import appex
                  from objc_util import *
                  app=UIApplication.sharedApplication()
                  url=nsurl('pythonista://')
                  app.openURL_(url)
                  appex.finish() #optional to close appex in containing spp, otherwise it will be there when you return.
                  
                  1 Reply Last reply Reply Quote 4
                  • omz
                    omz last edited by

                    @JonB Nice one! Didn't know that was possible.

                    Webmaster4o 1 Reply Last reply Reply Quote 0
                    • JonB
                      JonB last edited by

                      based on this... except that when I walked up the responder chain it turned out to be the sharedApplication()

                      1 Reply Last reply Reply Quote 0
                      • miwagner1
                        miwagner1 last edited by

                        This is fantastic. There are so many possibilities I can do now with pythonista and editorial with webpages. Right in the safari app.

                        1 Reply Last reply Reply Quote 0
                        • Webmaster4o
                          Webmaster4o @omz last edited by

                          @omz In the thread to which @JonB linked, people reported success with putting this method through apple review. You should implement this as the default behavior for webbrowser.open when called from appex.

                          1 Reply Last reply Reply Quote 0
                          • miwagner1
                            miwagner1 last edited by

                            No wonder he was surprised it worked. Apples docs say the UIApplication is Not available in app extensions.

                            It's possible this will break in later iOS versions.

                            1 Reply Last reply Reply Quote 1
                            • First post
                              Last post
                            Powered by NodeBB Forums | Contributors