views:

67

answers:

2

Hey, I am about to start working on an app. I am a beginner, so I am starting out with a pretty basic concept. But, I was wondering if it was possible to send texts from an app. For example, if the person using my app sets a new high score, could they hit a publish button and my app could then send a text to his buddy bragging about the new high score.

Also, what if someone is using my app and they receive a text, does the OS take over, or do I have to handle the reception of text/calls. Is it possible to alter the way the phone behaves when my app is disrupted by calls/texts.

Thanks for any advice you can give. Have a good Monday everyone!

+3  A: 

Apple's iOS documentation has a section that roughly covers how to incorporate in-app SMS.

Basically, your application displays an MFMessageComposeViewController as a modal view controller. It won't cause your app to terminate or background — it just lets your user send a text message, and when done, return to your app and continue.

When a phone call, text message or another notification comes in, your application delegate's applicationWillResignActive: method is called. It's up to you what you want your app to do while the user is dealing with the call, message or notification. If the call is declined or the alert dismissed, your application delegate's applicationDidBecomeActive: method is called and your application can resume as if nothing happened. Otherwise, the app either exits or backgrounds (depending on whether you want it to support multitasking), and you'll also have to handle it from there.

Also bear in mind what Toastor says about

  • Controlling whether messages can display to your user or not
  • Bills related to texting plans
BoltClock
Thanks. It seems to me that I will easily be able to text people from my app, once I figure a few things out. But, that makes it seem like I am not able to alter the way the phone handles the reception of text/calls while the user is using my app. Do you know if that is the case?
PFranchise
@PFranchise: I updated my answer.
BoltClock
Awesome, thank you very much for the edit. I think I will be able to do what I had in mind. Have a great day!
PFranchise
@BoltClock: O, one more quick question if you do not mind. Is it possible for my app to block incoming texts while my app is being run? Can I just simulate a rejection by the user?
PFranchise
@PFranchise: see Toastor's answer for that.
BoltClock
+2  A: 

There is no way to change the way the phone responds to calls. The only way to prevent your app from being interrupted by an incoming call is by activating the airplane mode on the device - which you cannot enforce from within the app.

Same goes for incoming texts - there is no way to notify your app if a message has been received. How would the system know if the message is meant for your app anyway?

The only thing you can actually do is send a text message from within your app. But if I were you I'd go either with established leaderboards or the new GameKit (have not checked this out yet myself, though).

Or, at least, use mail instead of text messages, since texts are not free in every country.

Toastor
@Toaster: Thank you very much for the good tips/ideas/comments. Do you know if it is possible to simply block a text while my app is being run? EDIT:After rereading your answer, it seems like this would not be possible. Thanks again and have a great day!
PFranchise
Yep, I'm afraid blocking / catching texts isn't possible either... Thanks and have a nice day too! :)
Toastor
Ah, That is too bad. I think I had a pretty neat idea. O well.
PFranchise