Twitter button in iOS - iphone

How do I put a Twitter button in my iOS app so the user can tweet their score?

Take a look at ShareKit: http://www.getsharekit.com/
It's pretty self explanatory, with documentation on the website
And it offers more than twitter, if you want it.

Just saw this question and thought I'd point out that with the upcoming iOS 5, there will be native Twitter support for every app. No technical/implementation details yet, obviously, but if you care to wait for a while you can get your hands on a native library, which will probably make your life a lot easier!
http://www.appleinsider.com/articles/11/06/09/inside_apples_ios_5_built_in_twitter_integration_makes_tweeting_a_snap.html (one source of many)

For anyone still interested, just read an awesome post on exactly this issue. See link for a step by step guide. He couldn't have made it any any easier :)
http://buildinternet.com/2011/10/tweet-sheet-creating-a-popup-tweet-in-ios-5/

Another option: DETweetComposeViewController
Works with iOS 4 and later.

Just check this blog post out for Twitter integration in iOS 5.
The advantage of using the tweet sheet is that it’s built right onto iOS, this means lots of things:
Standard interface throughout the OS
Automatic use of the user’s system Twitter account
Automatic check for a tweet less than 140 characters long
Easy image and link attachments
Easy to program, no need to implement OAuth or connect to the Twitter backend
As you can see we have lots of advantages and incentives to use this and, being that it’s so simple, there’s no excuse not to include Twitter functionality in your applications!

Just include the header file #import "Twitter/Twitter.h"
and add the framework Twitter.framework in the project..
and add the below lines for a button action
TWTweetComposeViewController *tweeter = [[TWTweetComposeViewController alloc] init];
[tweeter setInitialText:#"your score"];
[self presentModalViewController:tweeter animated:YES];
That all.. ur score will be posted...
If u want to add picture use [tweeter addImage:image ];
If u want to add url use [tweeter addUrl:#" your url"];

You can add an EasyTweet button to the app and where it says "Hello. This is a tweet." just add in the relevant content, ie "Just scored 42 points on YourApp.". This will be found in the ViewController.m file.

Related

Alternative to NSDistributedNotificationCenter for comms between iPhone apps

I've been looking for a way to compare timestamps between applications on the same phone in real time, and NSDistributedNotificationCenter sounded like an ideal solution since i may not know the names of the apps listening for it, but it sounds like its not available in iOS.
Is there an equivalent way of notifying multiple apps of a time-sensitive event without knowing their name?
Coding for iOS 5+ and assuming the apps in question will register for the notification.
Look at CPDistributedMessagingCenter in /System/Library/PrivateFrameworks/AppSupport.framework. However, it's a private framework (may change with OS releases, and not allowed in AppStore).
Documentation here: http://iphonedevwiki.net/index.php/CPDistributedMessagingCenter
Example codes of mine here:
https://github.com/H2CO3/PwnTube
https://github.com/H2CO3/Cereal
I'm pretty sure you can use Mach ports. They are a bit low level but work well.
i found a way to use CFNotificationCenterGetDistributedCenter() on iOS. It is exists on device, but not exports in iOS SDK
void *libHandle = dlopen("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", RTLD_LAZY);
CFNotificationCenterRef (*CFNotificationCenterGetDistributedCenter)() = (CFNotificationCenterRef (*)())dlsym(libHandle, "CFNotificationCenterGetDistributedCenter");
if(CFNotificationCenterGetDistributedCenter) {
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &NotificationUpdateApp, CFSTR("TestApp"), NULL, CFNotificationSuspensionBehaviorCoalesce);
}
dlclose(libHandle);
Not really. The closest you can do to what you’re asking, on a non-jailbroken device, is have your server talk to each other app’s server and have that server send a push notification to the app in question. Without NSDistributedNotificationCenter (which is, as you surmise, not available on iOS), you don’t really have any other option.
This question is a little bit old, but I'll post my answer just for information purposes.
NSDistributedNotificationCenter is not available for iOS yet, and unless your are developing an app that you don'd pretend to release on AppStore, you can't use AppSupport.framework because it's private.
iOS8 released App Extensions, that give us the ability to communicate with other apps. I don't know what you are trying to do exactly but I believe that if you are just trying to compare some timestamps from some other apps, it should resolve your problem.
Link to AppExtensions documentation:
https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/
Hope it helps somebody.
NSDistributedNotificationCenter exists on iOS, but the headers aren't made available to developers.
Create a header file in your project with the following to make the class available:
#interface NSDistributedNotificationCenter : NSNotificationCenter
+ (NSDistributedNotificationCenter *)defaultCenter;
// Returns the default distributed notification center - cover for [NSDistributedNotificationCenter notificationCenterForType:NSLocalNotificationCenterType]
- (void)postNotificationName:(NSNotificationName)name object:(nullable NSString *)object userInfo:(nullable NSDictionary *)userInfo deliverImmediately:(BOOL)deliverImmediately;
#end
This is very useful when trying to get information from an App to its UITest runner, but you should obviously NOT attempt to put this in the AppStore.
I've created a project XCTestBackChannel to show this off.

Open different websites from within an app

I would like to have an app which simple opens different websites for different languages. So the main purpose of the app is simple to redirect to an web app. My questions:
does Apple allow such apps (in the Appstore of course) ?
how can it be achived to be listed in the different istores (by country, according to the language)
how to I open different websites for different languages?
Thank You!
Apple does allow Apps that just contain UIWebView pointing to a website.
Use NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
to find the Country code
Using a simple condition, set the URL relavent to the country code.
1) Yes, it is allowed, though discouraged and highly annoying. I immediately uninstall apps that do this.
2) You'll have to setup localization for your app for each language you would like to represent
3) You simply setup a web site, and write it in the language you would like on the site. Localization will save time here, too.
Although this might draw some traffic to your sites, it is not a good business model and you should probably try to make your app do something of benefit for the user. If your app is useful, you will get more than enough traffic to your sites through gentle prodding or in-app announcements of some kind.

Upload picture to twitter from iPhone

Is it possible to programmatically upload a picture to twitter from iPhone?
Can this be done through twitter directly, or do I need to use a third-party service like Twitpic?
Thanks for editing your question. It makes more sense now. I'm leaving my original answer up so that this thread doesn't become confusing.
Anyway, the answer is short: the Twitter API doesn't provide a way for you to upload a photo directly with a status update, so I'm fairly certain you need to use a third-party service. The official Twitter client uses yFrog by default, but it lets you change the service to TwitPic, TweetPhoto, Mobypicture, Twitgoo, Posterous, img.ly, or a custom service.
Just use http://github.com/Gurpartap/GSTwitPicEngine.

How to show related city name according to the incoming call on iPhone?

I want to add something (eg. the related city name) into the UI view when I make a phone call or received a phone call on iPhone. However, I can't figure out a good solution for this idea. Could anyone who has experience on this subject gives me some suggestions?
My currently solution is, try to write an extension based on mobile substrate and hook functions in SpringBoard. So many difficulties existed and following are my current big questions,
How to develop such a extension? I downloaded some examples from google, unfortunately they cann't even be compiled on my toolchain.
I can't figure out which ui view for the related screen I should use to insert my own component. I get header files of SpringBoard via class-dump, but no docs and no comments about its usage. Could someone share his discoveries with me?
How to build a trusted cross-compiling enviroment on leopard? All kinds of confusing errors pop up when I try to build others's codes. I've tried Zdziarski's instrunctions in his book, it works with iPhone OS 1 and can compile common projects with open sdk, but how should I do to make it works when comipiling ms plugins?
Also, is there any other solution to translate my ideas to codes? I start iPhone development one month ago, no experience with cocoa/Obj-C before. So your suggestions are very appriciated.
~ Link Bian (卞林扣)
Email/MSN: linkou.bian#gmail.com
I think you are asking for too much. It wont be possible to manipulate incoming/outgoing call screens. Ethically, that is.
Zdziarski is a hacker and from his book, you will get many undocumented API calls which will make Apple reject your app. Same goes for Erica Sadun's iPhone Developer's Cookbook.
Something that really helped me get dylibs compiled was using SkylarEC's Xcode template and just appended an extension of '.dylib' onto the binary and sshing it into /Library/MobileSubstrate/DynamicLibraries. I suggest hooking SBCallAlert or SBCallAlertDisplay to get the id of the caller which is usually just an NSString. Play around with it a little bit, those are all the visualizing methods of a call. If you put in an nslog in your custom override method, you can view the output in iPhoneConfgurationUtilitie (windows) or the console in Xcode. From there you would most likley need an index of area codes to comare the callers to. I don't believe you can add subviews to the call, on I intercept and reissue the strings for the views already there.
But you know, apple doesn't like this :P
lemme know if this helps

How do you prompt the user to rate your iphone app without waiting for them to delete the app?

I am referring to the popup window that asks the user to submit a review/rating.
I know it can be done since the Aardark app does it...it asks several times in fact! (Almost too spammy.) But there has to be an API to trigger the rating request? Google is giving me no love on this one.
I would check out the Appirater project that Arash Payan has put together.
Pretty much handles the checking and displaying of the "rate my app" prompt, and brings the user right into the review portion of your app on the App Store.
It's a very clean, and elegant way to provide that minimum barrier so that your users are more likely to submit reviews of your app.
Hope this helps...
I have written about a way to open right into the review panel of the App Store.
http://www.memention.com/blog/2009/09/03/Open-Reviews.html
The actual code part if called through a button press could look like below
- (IBAction)gotoReviews:(id)sender
{
NSString *str = #"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa";
str = [NSString stringWithFormat:#"%#/wa/viewContentsUserReviews?", str];
str = [NSString stringWithFormat:#"%#type=Purple+Software&id=", str];
// Here is the app id from itunesconnect
str = [NSString stringWithFormat:#"%#289382458", str];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
I wrote a library to do this - similar to Appirater but a bit more configurable and with Mac App Store support:
https://github.com/nicklockwood/iRate
I have discovered the most subtle value of S.O. (already obvious to all elementary school teachers) --- often by simply forming your question, your neurons rearrange and you are more successful at answering it yourself! (Either that or Google optimized my search after spying on my keystrokes and indexing my question on S.O.)
Answer found after more productive googling:
http://www.mobileorchard.com/fighting-back-against-the-app-stores-negative-rating-bias/
this may not be what youre looking for EXACTLY but what i would do is just prompt them in the app somehow and somewhere not too annoying with a button or alert view and have that button link them to app url in safari which opens the appstore to your app. you can use the url http://www.itunes/apps/ (your app) as i believe is the synthax. i cant remember the exact code but i can get it for you if need it.
We AskingPoint have another way to do it (Im a founder) that provides BOTH App Analytics and the rating widget. You can adjust server side settings based on your analytics to prompt only your best users. Change settings on the fly. And it's translated into over 30 languages.
I wanted to do this when I roll the app out for the first time... looks like I'll have to wait and put it out as an update to ensure that it will work... let me know if I am wrong and there is some way I can test this before submitting to apple for distribution.