Open native Twitter App from my Application using IBAction - objective-c

I'd like to implement the natvie Twitter App into my iOS Application.
I've already done that with Facebook by using the URL Schemes. But I weren't able to find such thing for Twitter.
For Facebook I used:
-(IBAction)facebook:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"fb://"]];
}
But when I try to use
#"Twitter" or #"twitter" or #"tw"
nothing happens.
Would be great if you guys could help me out. I haven't found anything in the Interweb :/
If there is something just like it please :)
Thanks in advance :)

Did you try:
twitter://
ex:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"twitter://user?screen_name=username"]];

Related

Xcode iOS: Calling a number from the app

I across the following code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://8005551212"]];
on : Making phone calls on iPhone
But, it does not work for me in the simulator.
I have connected the IBAction(callphone) to the ViewController(TouchUpInside). I am now not sure, is it because I am checking my code in simulator? I do not get a dialog box. Please advice.
I tried putting log statements and the action does get called since the log stamtments that I wrote to test is being printed
Can you make a phone call from your Mac? No. That's why the simulator doesn't work when you try to open a tel:// URL. You must do this from a device that can make a call: an iPhone, but not an iPad or iPod touch.

Is it possible to request an APNS Device Token from the View Controler?

I'm new to Objective-C and iOS development, but I was wondering if there was a way to request an Apple Push Notification Device Token from the View Controller and store the token in a string to use later in a Query String sent to my web application.
I've been searching, but haven't been able to find a solution to this. Any help would be appreciated!
You should be able to call registerForRemoteNotificationTypes: anywhere in your code.
But you'll have to implement application:didRegisterForRemoteNotificationsWithDeviceToken: in your app delegate.
You can register for up to 3 different types of notification. Just remove and add as required.
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeAlert | //Alerts are pop up boxes or on ios5, banners
UIRemoteNotificationTypeBadge | //Badges are the little red number on the icon
UIRemoteNotificationTypeSound)]; //Sounds are... well, sounds. These can be played when presenting a remote notification

Go to iPhone maps app from another app

I'm writing an app where I want the user to be able to get directions. I know about the google API, and I have that implemented, but I was wondering about ways to jump directly to the native Maps app and give the user directions instead. I think I've seen it done before, but I could be mistaken.
Any help is much appreciated.
You can open the maps app by using regular URL that points to Google Maps. From the Apple URL Scheme reference:
The maps URL scheme is used to show geographical locations and to generate driving directions between two points. If your application includes address or location information, you can use map links to forward that information to the Maps application on iOS and the Google Maps website on other platforms.
Unlike some schemes, map URLs do not start with a “maps” scheme identifier. Instead, map links are specified as regular http links but are targeted at the Google Maps servers. The following examples show the strings you would use in Safari and in a native application to show a map of the city of Cupertino, California.
HTML link:
Cupertino
Note that on a device that does not have maps installed (not sure if those even exist), the link will open in a regular browser, since it is simply an HTTP link.
To open the URL, you can present the link in a UIWebView, or you can use code to open it. for example:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://maps.google.com/maps?q=Cupertino"]];
If you wanted to pass in a custom location and open it when the user taps a button, you can make a method like this:
- (IBAction) openMapsAppAndShowLocation:(NSString *)locationToShow{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://maps.google.com/maps?q=%#", locationToShow]]];
}
If you wanted, you could refactor the method to take latitude/longitude pair too. That might look like this:
- (IBAction) openMapsAppAndShowLatitude:(double)latitude andLongitude:(double)longitude{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://maps.google.com/maps?q=\"%f,%f\"", latitide, longitude]]];
}
You can use either this:
NSString *latlong = #"-56.568545,1.256281";
NSString *url = [NSString stringWithFormat: #"http://maps.google.com/maps?ll=%#",
[latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
this,
UIApplication *app = [UIApplication sharedApplication];
[app openURL:[NSURL URLWithString: #"http://maps.google.com/maps?q=London"]];
or this
[someUIApplication openURL:[[NSURL alloc] initWithString: #"http://maps.google.com/maps?q=London"]]
You can even specify the zoom level using the z flag (values between 1-19):
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://maps.google.com/maps?z=8"]];
That should invoke the Google Maps app. I think that these instructions only work on the actual device and NOT in the simulator. Good luck and comment below if you have any problem with the snippets :)
Very simple
UIApplication *app = [UIApplication sharedApplication];
[app openURL:[NSURL URLWithString:#"http://maps.google.com/maps?q=London"]];
Easy as a kiss
#Moshe
Note that on a device that does not have maps installed (not sure if those even exist)
Take an iPhone simulator for example.

App Crash on Working with Facebook Connect

While I'm testing my app, is an UITableViewController navigation based app, sometimes, getting back or changing the view for another, I'm getting the next crash message. I can't solve this error, I don't know what is the responsible of this. Somebody can help me?
Thanks for reading.
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
When the app has finish, XCode points this Facebook Connect method.
- (void)dialogDidSucceed:(NSURL *)url {
if ([_delegate respondsToSelector:#selector(dialogCompleteWithUrl:)]) {
[_delegate dialogCompleteWithUrl:url];
}
[self dismissWithSuccess:YES animated:YES];
}
Now the problem is solved. The best way to use the Facebook Connect SDK is to implement all the Facebook related objects into the App Delegate. When the user touch the button that allow to post into him Facebook wall (doesn't matter the UIView where the user is), you only have to call the App Delegate and get the Facebook objects that you need to call the Facebook Connect dialog. The App Delegate must be the Facebook Connect delegate for FBDialogDelegate and for FBSessionDelegate. Also, the App Delegate must implement the application: handleOpenURL: method.
Thanks to everyone for reading.

Objective-C launch iTunes in background

I want to launch iTunes but i don't want the launch to be visible, at the moment the code i have navigates to the space which iTunes is assigned to and makes iTunes the key window, so effectively i want it to launch in the background.
[[NSWorkspace sharedWorkspace] launchApplication:#"iTunes"];
Can anyone help? Thanks.
I think this is what you want:
[[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:#"com.apple.iTunes" options: NSWorkspaceLaunchDefault | NSWorkspaceLaunchWithoutActivation additionalEventParamDescriptor:nil launchIdentifier:nil];
The important bit is NSWorkspaceLaunchWithoutActivation.
Edit: As also posted, you can use NSWorkspaceLaunchAndHide as well, if you want iTunes to be hidden.
Use -launchApplicationAtURL:options:configuration:error: to launch it, and include NSWorkspaceLaunchAndHide in the options.
Should this work for you?
(NSRunningApplication *)launchApplicationAtURL:(NSURL *)url options:(NSWorkspaceLaunchOptions)options configuration:(NSDictionary )configuration error:(NSError *)error