Sha256: 5c47c6b98a3948cd955970de7ac6bdbed2925ebd219348dd7c27b4c9662fe656
Contents?: true
Size: 1.73 KB
Versions: 4
Compression:
Stored size: 1.73 KB
Contents
module BubbleWrap module SMS module_function # Base method to create your in-app mail # --------------------------------------- # EX # BW::SMS.compose ( # { # delegate: self, # optional, will use root view controller by default # to: [ "1(234)567-8910" ], # message: "This is my message. It isn't very long.", # animated: false # }) {|result, error| # result.sent? # => boolean # result.canceled? # => boolean # result.failed? # => boolean # error # => NSError # } def compose(options={}, &callback) @delegate = options[:delegate] || App.window.rootViewController @callback = callback @callback.weak! if @callback && BubbleWrap.use_weak_callbacks? @message_controller = create_message_controller(options) @message_is_animated = options[:animated] == false ? false : true @delegate.presentModalViewController(@message_controller, animated: @message_is_animated) end def create_message_controller(options={}) message_controller = MFMessageComposeViewController.alloc.init message_controller.messageComposeDelegate = self message_controller.body = options[:message] message_controller.recipients = Array(options[:to]) message_controller end # Event when the MFMessageComposeViewController is closed # ------------------------------------------------------------- # the callback is fired if it was present in the constructor def messageComposeViewController(controller, didFinishWithResult: result) @delegate.dismissModalViewControllerAnimated(@message_is_animated) @callback.call Result.new(result) if @callback end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
bubble-wrap-1.6.0 | motion/sms/sms.rb |
bubble-wrap-1.6.0.rc1 | motion/sms/sms.rb |
bubble-wrap-1.5.0 | motion/sms/sms.rb |
bubble-wrap-1.5.0.rc1 | motion/sms/sms.rb |