Sha256: 433fb016b7c3c1e65037fe7d913dba8d6d99f90c8d38467293425d37abce38d2
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bubble-wrap-1.7.1 | motion/sms/sms.rb |
bubble-wrap-1.7.0 | motion/sms/sms.rb |