I am using IRate in my ios application.
I had coped two classes of iRate in my code. This is my code in appDelegate
+ (void)initialize
{
//set the bundle ID. normally you wouldn't need to do this
//as it is picked up automatically from your Info.plist file
//but we want to test with an app that's actually on the store
[iRate sharedInstance].applicationBundleID = #"com.s.s";
[iRate sharedInstance].onlyPromptIfLatestVersion = NO;
//enable preview mode
[iRate sharedInstance].previewMode = NO;
//[iRate sharedInstance].daysUntilPrompt = 5;
//[iRate sharedInstance].usesUntilPrompt = 15;
}
But by this the promt can only come at start of app.
I want to open it in button click.
Thanks for Help
You can lead the user to appstore and review your app directly. Add this line to your button click action:
[[iRate sharedInstance] openRatingsPageInAppStore];
Related
I am working with Share kit for Facebook sharing. and using action sheet to open a Facebook popup. Its working fine on iOS 6 or previous version.
But in iOS 7 its automatically disappeared on action sheet button click.
Please guide me.
Thanks
Find the method -(void)showWebView in FBDialog.m (around line 410).
Replace this code
if (!window) {
window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}
With this
if (window.windowLevel != UIWindowLevelNormal) {
for(window in [UIApplication sharedApplication].windows) {
if (window.windowLevel == UIWindowLevelNormal)
break;
}
}
I've tested it on iOS7 and iOS6, it works.
Have a nice day :)
Is there a way to tell if an iOS app enters the foreground from fast-app switching or manually? I need to know by the time applicationWillEnterForeground is called, so some specific code can be executed (or not executed) depending on the condition in which the app entered the foreground.
EDIT:
It turned out that this was more of a design issue for me. I moved my code to applicationDidBecomeActive. I also added a BOOL property to the appDelegate called fastAppSwitching (probably the wrong name for it). I set this to YES in application:handleOpenURL and application:openURL:sourceApplication:annotation. Then I added the following code to application:didFinishLaunchingWithOptions:
if (launchOptions) {
self.fastAppSwitching = YES;
}
else {
self.fastAppSwitching = NO;
}
In applicationDidBecomeActive, I used the following code:
if (fastAppSwitching == YES) {
self.fastAppSwitching = NO; //stop, don't go any further
}
else {
...
}
EDIT2: MaxGabriel makes a good point below: "Just a warning to others taking the solution described here, applicationDidBecomeActive: is called when the user e.g. ignores a phone call or text message, unlike applicationWillEnterForeground". This is actually also true for in-app purchases and Facebook in-app authorization (new in iOS 6). So, with some further testing, this is the current solution:
Add a new Bool called passedThroughWillEnterForeground.
In applicationWillResignActive:
self.passedThroughWillEnterForeground = NO;
In applicationDidEnterBackground:
self.passedThroughWillEnterForeground = NO;
In applicationWillEnterForeground:
self.passedThroughWillEnterForeground = YES;
In applicationDidBecomeActive:
if (passedThroughWillEnterForeground) {
//we are NOT returning from 6.0 (in-app) authorization dialog or in-app purchase dialog, etc
//do nothing with this BOOL - just reset it
self.passedThroughWillEnterForeground = NO;
}
else {
//we ARE returning from 6.0 (in-app) authorization dialog or in-app purchase dialog - IE
//This is the same as fast-app switching in our book, so let's keep it simple and use this to set that
self.fastAppSwitching = YES;
}
if (fastAppSwitching == YES) {
self.fastAppSwitching = NO;
}
else {
...
}
EDIT3: I think we also need a bool to tell if app was launched from terminated.
If your application is launched by another application, the
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
sourceApplicarion:(NSString *)bundleID
annotation:(id)info;
method is called on your app delegate. You can use this method to e. g. set a Boolean switch to true that indicates whether the app was launched by another program.
The peoblem is that this method is called after applicationWillEnterForeground:, so you can't tell in that method whether your app was launched manually or automatically.
However, I suspect that if you need this to be detected in a particular method, you may have a design problem and you should probably reorganize your code.
In the case where your app is opened from another app, application:openURL:sourceApplication:annotation will be called on your app delegate.
I have a popular medicine app often used by med students and residents at the bedside. I incorporated the new FB SKD into my last updated which, when opened for the first time (and subsequently if not used for a few days), opens the native FB app then redirects to my app. Many customers have complained because the info within the app often needs to be looked up quickly (crashing patient).
Is it possible to set up my app so the user needs to click on a button within the app before connecting to FB? Thanks!
I think you will need to make change to authorizeWithFBAppAuth method in facebook.m file of the SDK.
This SO has a suggestion for you.
When you download the FB SDK you get a sample project. Compile and run it, and you should see a toggle button that allows user to login/logout. You've got the FB official images in that project, and the code behind it is pretty simple:
/**
* Called on a login/logout button click.
*/
- (void)fbButtonClick:(id)sender {
if (fbButton.isLoggedIn) {
[self logout];
} else {
[self login];
}
}
/**
* Show the authorization dialog.
*/
- (void)login {
[_facebook authorize:nil delegate:self];
NSLog(#"Sas");
}
/**
* Invalidate the access token and clear the cookie.
*/
- (void)logout {
[_facebook logout:self];
}
You should also change the button's state in the FBAuth delegate methods (which you've already implemented) by calling a method similar to this one:
- (void)updateFbButtonAccordingToSessionStatus {
//Check if session is valid and update button accordingly
if ([self.facebook isSessionValid] == NO ) {
fbButton.isLoggedIn = NO;
[fbButton updateImage];
}
else {
fbButton.isLoggedIn = YES;
[fbButton updateImage];
}
}
Hope this helps.
I'm trying to integrate my game with Game Center and encountered this problem:
When user is authenticated for a first time, Game Center shows its UI for setting up the profile.
My problem is that I can not detect when this windows is shown - I want to pause my game at that moment and not play any sounds.
viewWillDisapper, viewDidDisapper in UIViewController are not called, neither are any of AppDelegate methods are called at this time.
I think I know how detect alert views (using changing key window notification), but that Account windows still is not detected there.
Is there any way to do this?
Building on executor21's answer here, I put this together which seems to do the trick in early testing. You can probably adapt it into something less fragile. It is built on the premise that the Game Center notification gets its own window, and it has exactly one subview of type GKGameEventView:
+(BOOL)isGameCenterNotificationUp
{
NSArray *windows = [[UIApplication sharedApplication] windows];
for(UIWindow *win in windows)
{
NSArray *winSubViews = [win subviews];
if([winSubViews count] == 1)
{
Class gcNotificationClass = NSClassFromString(#"GKGameEventView");
if(gcNotificationClass && ([[winSubViews objectAtIndex:0] isKindOfClass:gcNotificationClass]))
{
return YES;
}
}
}
return NO;
}
I have a MenuViewController that loads when the app loads up; it is the root view of a UINavigationController.
Within the view I have a UIButton with an image that loads from a URL, as well as a label (its a picture indicating the weather and the current temp.).
Everything works fine, but if I am using the app on an iPhone 4, with multi-tasking, when the home button is pressed and then the app is reopened, I need the UIButton image and temp. label to reload.
I have tried calling this in my AppDelegate under applicationDidBecomeActive:
[self parseWeatherXML]; //re-parse weather data
[menuViewController reloadWeatherData]; //loads the image/label from the XML
with no luck.
I have also tried releasing menuViewController in applicationWillResign, then reallocating menuViewController in applicationDidBecomeActive so the viewDidLoad method gets called again, both ways just end up crashing my app.
Any help appreciated!
EDIT
Heres my method that gets called with the notification:
- (void)reloadWeather
{
[self parseWeatherXML];
UIImage *img = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString:iconURL]]];
if (img != nil)
{
NSLog(#"setting image");
[weatherButton setImage:img forState:normal];
img = nil;
}
currentTemp = [currentTemp stringByAppendingString:#"°F"];
[tempLabel setText:currentTemp];
tempLabel.adjustsFontSizeToFitWidth = YES;
if([self isIPad])
{
tempLabel.textAlignment = UITextAlignmentRight;
[tempLabel setFont: [UIFont systemFontOfSize: 45.0]];
}
currentTemp = nil;
}
I would have your MenuViewController become an observer to the UIApplicationDidBecomeActiveNotification and perform the parseWeatherXML data. I would think you would be refreshing the data from the URL, so you would need to wait for that data to come back again. So, I would follow the same logic that you are doing when you receive that notification.
UIApplicationDidBecomeActiveNotification
Posted when the application becomes
active. An application is active when
it is receiving events. An active
application can be said to have focus.
It gains focus after being launched,
loses focus when an overlay window
pops up or when the device is locked,
and gains focus when the device is
unlocked.
Availability
Available in iOS 2.0 and later.
Declared In
UIApplication.h
Have you tried saving the image and temp using a plist or something, during the applicationWillResign, and then during applicationDidBecomeActive, you can reload the image and temp from the saved file/label. Just another option to explore.