module BubbleWrap::SMS

Public Instance Methods

can_send_sms?() click to toggle source
# File motion/sms/sms.rb, line 40
def can_send_sms?
  !!MFMessageComposeViewController.canSendText
end
compose(options = {}, &callback) click to toggle source

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
}
# File motion/sms/sms.rb, line 22
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
create_message_controller(options = {}) click to toggle source
# File motion/sms/sms.rb, line 32
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
messageComposeViewController(controller, didFinishWithResult: result) click to toggle source

Event when the MFMessageComposeViewController is closed


the callback is fired if it was present in the constructor

# File motion/sms/sms.rb, line 48
def messageComposeViewController(controller, didFinishWithResult: result)
  @delegate.dismissModalViewControllerAnimated(@message_is_animated)
  @callback.call Result.new(result) if @callback
end