Showing sms dialog in ios for certain number - objective-c

I know iOS is very strict about accessing sms and user data. But I wish to implement simple feature, something like log.
In my app user sends sms to another number (robot). And gets it's state back in sms. I know I can't access them in any way. But maybe I can set up a button which would simply show sms from certain number if there are any. Just to open Messages for a certain number that's all.
Is that possible, and can be accepted by Apple?

You can only send an sms. You cant view any messages. Check the apple documentation here.
Apart from usage of MFMessageComposeViewController, only option you have is to open the message app as,
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"sms:"]];
Or just to pop up the sms app with number as,
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"sms:1234567890"]];
Here is a similar question.
Update:
If you want to do this inside your app, you can use MFMessageComposeViewController. Check this apple documentation for more details on this.

Related

How to share with messages, mail, print and copy

I've seen some apps that allow you to share content with ios's mail, messages, print and copy.
I see there is a project called sharekit that does something similar but integrates social network sharing. Personally I don't need the social sharing, so sharekit it probably overkill.
I just need to popup an actionsheet that will allowe me to pass some text for example to the mail app or the messages app.
What you are looking for is the MessageUI.framework.
This framework contains:
MFMailComposeViewController
this class will allow your user to compose an e-mail.
MFMessageComposeViewController this class will allow your to compose a SMS message. MMS is not supported.
You will have to write the action sheet you self, but after the user made there choice you can create an instance of MFMailComposeViewController or MFMessageComposeViewController and present it to the user.
Be aware that you will need to implement the MFMailComposeViewControllerDelegate and/or MFMessageComposeViewControllerDelegate to dismiss the view.
Look my answer here:
https://stackoverflow.com/a/13975189/736384
I wrote about the new UIActivity control, It let you do all you are looking for.
If all you want to do is integrate with Mail or Messages, use the MFMailComposeViewController and MFMessageComposeViewController classes respectively.
If you want to add support for Copy, Print, and other such "activities', take a look at the documentation for UIActivity and UIActivityViewController.

iOS 6 send email without user interaction

First of all, I'm working on an in-house app, so I don't need approval at App Store. I know it wouldn't ever be accepted, but it's a business rule our users share some content of the application, but with a default message and subject, so they can't edit these fields..
Until iOS 5 I was able to navigate by the view hierarchy and let the fields unneditable. But with iOS 6, and the mail on another proccess, I can't do it anymore.
I need to block the views for editing (I put a view over all the mail view, except the title bar, and it works, but when the user try to cancel the e-mail, my view is blocking the popover to delete or save draft too) or send e-mails without the UI (I was able to do it with Stealth Messenger based code (https://github.com/0xced/Stealth-Messenger/) at iOS 4 or 5, but now it doesn't work).
I tryed everything I could with private APIs and Objective-C runtime.. I can dismiss the view with sending e-mail ok, but the e-mail itself isn't sent.
Can anybody help me? Does anybody did it?
Thanks in advance..
Take a look at this: Send Email in Background from iOS
IOS doesn't support to mail in background. [...] As an alternate you
should implement the WebService for this[...]
Probably the best option is to utilise some server code and call that with NSURLRequest.
Hope that helps.
I do this in an app of mine. I have a simple PHP script on a webserver that uses the PearPHP mail modules to send SMTP mail. The PHP script takes a few incoming variables, like $toAddress, $subject, $message and then connects to the SMTP server and sends the mail out.
Unfortunately, you're not allowed to subclass the MFMailComposeViewController, and if you were using some sort of Invisible UIView to block fields, that was just a workaround that's probably been broken. (They did the same thing with being able to insert a "." on the NumberPad keyboard)

iOS 5: Can I have my app "In Notification Center" by default?

I have an iPad app in the App Store whose logic relies largely on local notifications. In other words, much that happens inside the app is triggered by the delegate method application didReceiveLocalNotification.
With today's release of iOS 5, I see that apps can be placed (via Settings) either "In Notification Center" or "Not In Notification Center." I haven't found anything in the new documentation so far, but I'm hoping there is a way to have my app "In Notification Center" by default, (and possibly even set Sounds active and the notification type to Alert) which would save me having to explicitly explain to new users that after they download & install my app, they will have to manually go and elect for the app to be "In Notification Center."
Anyone know if this is possible? Seems that since an app can register a local notification, it should be able to receive it, by default (whether it displays an alert or an item in the new Notification Center, or not). Thanks in advance.
I've encountered the same problem. The only clue I saw in documentation is that the new Notification Center handles both local and remote notifications. Therefor I assumed that the app should register for local as it would for remote notification. Added this piece of code -
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
and after my app scheduled a local notification it appeared at the "In Notification Center".
BUT it seems to have no affect if my app already appears in "Not In Notification Center".. So have all of my customers that ran the app before the next update got screwed?
Currently it seems not.
I'm in a similar situation. I'd love to be wrong about this but I've found no mention of any such API (for specifying that a local-notification using app should appear in notification center by default) in any of the places I'd expect it to be:
Local and Push Notification guide
UIApplication class reference
UIKit Info PList keys
UIApplicationDelegate Protocol reference

How to programmatically add calendar subscriptions on iOS?

Via the settings panel of your iPhone, you can add a subscription to a remote .ics calendar format. I have a Dutch iPhone app that does this from within the app (see the screenshot below, "abonneren op de agenda" means "subscribe to the calendar"), but there must be others too.
I want to mimic this behavior for a project of mine, but I can't find the API to do this with. It looks like it's not a part of EventKit, but because there's no app switching going on when you hit 'subscribe' in the example app I suspect it's also not a url scheme.
Who knows?
Try something like this:
NSString *url = #"http://server/filename.ics";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
This shows an uialertview with the question to the user if he/she wants to subscribe.
;)

Sent text to notes

I'm trying to add a 'copy to notes' button in my app which sends a text to the notes app of ios. Is there any possible way to integrate this?
I've done some research and didn't find anything and since I've never seen it in an other app I guess it's not possible, but I thought It was worth a question.
Good question. Situations like the one you describe are always handled with URL schemes using the UIApplication method openURL:. For example, to launch the phone app with a specific number you could do:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:1-234-567-8910"];
Or to launch the Mail app:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"mailto:nobody#example.com"];
Just to show a few examples. The Apple URL Scheme Reference document describes all of the various URL schemes to integrate with different system apps. Nowhere in this document does it mention a URL scheme for the built in Notes app. If it were possible to send text to the Notes app, I would expect the document to advertise the fact. While it's not conclusive proof that it's not possible, I still think it should be cited as strong evidence of such.
Note that there are likely several third party note-taking apps that have their own custom URL scheme that may support launching with text.