Skip to content

Instantly share code, notes, and snippets.

@akshayaurora
Created May 31, 2022 15:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akshayaurora/82a7798284d45cf56f8be14f42b6c0cc to your computer and use it in GitHub Desktop.
Save akshayaurora/82a7798284d45cf56f8be14f42b6c0cc to your computer and use it in GitHub Desktop.
Kivy Share file on iOS
app = App.get_running_app()
import ios
from pyobjus import autoclass
NSURL = autoclass('NSURL')
UIApplication = autoclass('UIApplication')
sharedApplication = UIApplication.sharedApplication()
def do_share_ios(data, title):
URL = NSURL.fileURLWithPath_(data)
UIActivityViewController = autoclass('UIActivityViewController')
UIcontroller = sharedApplication.keyWindow.rootViewController()
UIActivityViewController_instance = UIActivityViewController.alloc().init()
# print(dir(UIActivityViewController_instance))
activityViewController = UIActivityViewController_instance.initWithActivityItems_applicationActivities_([URL], None)
UIcontroller.presentViewController_animated_completion_(activityViewController,True, None)
out_file = app.user_data_dir + '/result.json'
with open(out_file, 'w') as ofile:
import json
json.dump(self.results, ofile, indent=4)
do_share_ios(out_file, 'Some title')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment