IAP doesn't work on Real iPad - xcode

When I run the following code in simulator, it can get the IAP info successfully, but when it run on a real IPAD, "count" always = zero ... any ideas what's wrong?? Thanks.
// Store Kit returns a response from an SKProductsRequest.
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
// Populate the removeAdsButton button with the received product info.
SKProduct *validProduct = nil;
int count = [response.products count];
if (count>0) {
validProduct = [response.products objectAtIndex:0];
}
if (!validProduct) {
[removeAdsButton setTitle:#"No Products Available" forState:UIControlStateNormal];
removeAdsButton.enabled = NO;
return;
}
NSString *buttonText = [[NSString alloc] initWithFormat:#"%# - Buy $%#", validProduct.localizedTitle, validProduct.price];
[removeAdsButton setTitle:buttonText forState:UIControlStateNormal];
removeAdsButton.enabled = YES;
[buttonText release];
}

I found that if the device is JB, it won't work..

Related

Facebook publish_actions deprecated

What can I do to use as an alternative to publish_actions? I have a photo app that lets users share their photos to their profile. Currently it uses logInWithPublishPermissions:#[#"publish_actions"] and then shares the files through FBSDKSharePhoto. But after August 1 this will be removed. Any thoughts? This is my current code but soon it won't work.
-(IBAction)loginToFacebook:(id)sender
{
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
login.loginBehavior = FBSDKLoginBehaviorWeb;
[login logInWithPublishPermissions:#[#"publish_actions"]
fromViewController:self
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(#"Process error");
} else if (result.isCancelled) {
NSLog(#"Cancelled");
nonpressTimer = [NSTimer scheduledTimerWithTimeInterval:15.0 target:self selector:#selector(timeout) userInfo:nil repeats:NO];
} else {
NSLog(#"Logged in");
[self shareSegmentWithFacebookComposer];
}
}];
}
- (void)shareBoothOnFacebook {
NSUserDefaults *defaults2 = [NSUserDefaults standardUserDefaults];
NSData *data6 = [defaults2 objectForKey:#"layoutphoto"];
UIImage *myImage = [NSKeyedUnarchiver unarchiveObjectWithData:data6];
NSMutableArray *photos = [[NSMutableArray alloc] init];
for (int i = 0; i < [self.arrSlidshowImg count]; i++) {
UIImage *image = [UIImage imageWithData:[_arrSlidshowImg objectAtIndex:i]];
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image;
photo.userGenerated = YES;
[photos addObject:photo];
}
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = [photos copy];
[FBSDKShareAPI shareWithContent:content delegate:nil];
}
}
You'll need to switch to using Facebook's iOS sharing APIs which require that the Facebook Messenger app is installed. See their documentation on sharing.
You might also want to investigate the use of the iOS share sheet but that also requires the Facebook Messenger app to be installed to enable sharing to Facebook.

IOS 8 Addressbook kABPersonEmailProperty

I developed one application. It is working perfectly in IOS 7. But IOS 8 I have issues. I implement the function get the contact information from address book.
So I implement the method
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{
[self gettingContactInfo:person];
[self dismissViewControllerAnimated:YES completion:nil];
return NO;
}
This method is perfectly working in IOS 7. But IOS 8 not working.
So I developed other method
-(void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person{
[self gettingContactInfo:person];
[self dismissViewControllerAnimated:YES completion:nil];
}
But after this method I am always getting email is empty. What is the mistake i did?
Email getting method
_emailArray = [[NSMutableArray alloc]init];
ABMutableMultiValueRef emailsRef = ABRecordCopyValue(person, kABPersonEmailProperty);
if (ABMultiValueGetCount(emailsRef) > 0) {
// collect all emails in array
for (CFIndex i = 0; i < ABMultiValueGetCount(emailsRef); i++) {
CFStringRef emailRef = ABMultiValueCopyValueAtIndex(emailsRef, i);
NSString *currentEmail=(__bridge NSString *)emailRef;
NSLog(#"%#",currentEmail);
[_contactInfoDict setObject:currentEmail forKey:CONTACT_EMAIL];
[_emailArray addObject:currentEmail];
CFRelease(emailRef);
}
}
if (emailsRef) {
CFRelease(emailsRef);
}

zooming on Mapview Crashes the app on iOS6

i am using mapview. when i zoomin on map it shows did recieve memory warning and crashes the app in iOS 6 devices .but its working fine in below versions. Its taking more memory when i zoom in but its not getting released how to release it i haved deallocated all the objects in deallocation method but it still shows same did receive memory warning and crashes the app
my code is
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
mapView.showsUserLocation = YES;
[mapView setDelegate:self];
[self addSubview:mapView];
routeView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, mapView.frame.size.width, mapView.frame.size.height)];
routeView.userInteractionEnabled = NO;
[mapView addSubview:routeView];
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if([annotation isKindOfClass:[TurnAnnotation class]])
{
MKAnnotationView *turnAnnotationView=[[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:nil] ;
turnAnnotationView.image=[UIImage imageNamed:#"TurnAnnotation1.png"];
turnAnnotationView.canShowCallout=NO;
return turnAnnotationView;
}
else if([annotation isKindOfClass:[PlaceMark class]])
{
MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
if (isdefault==YES) {
if(!appDel.appBOOL){
newAnnotation.pinColor = MKPinAnnotationColorGreen;
appDel.appBOOL = YES;
}else {
newAnnotation.pinColor = MKPinAnnotationColorRed;
appDel.appBOOL = NO;
}
}else{
if(!appDel.appBOOL){
newAnnotation.pinColor = MKPinAnnotationColorRed;
appDel.appBOOL = YES;
}else {
newAnnotation.pinColor = MKPinAnnotationColorGreen;
appDel.appBOOL = NO;
}
}
newAnnotation.canShowCallout = YES;
return newAnnotation;
}
return nil;
}
Could it be that your iOS6 testcase is a Retina version? Retina imagery take up 4x the memory. The low memory warning should notbe ignored..

Manage memory allocation issue on Map iOS

In my iPhone app I have a map view. In this I am displaying a number of pin views depends on the data from a web server. Here is the method I used for it.
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
NSString *identifier = #"myPin";
self.pinView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (self.pinView == nil) {
self.pinView= [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]autorelease]; //11.1%
} else {
self.pinView.annotation = annotation;
}
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; //20.4%
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
self.pinView.rightCalloutAccessoryView = rightButton; //2.7%
MyAnnotation *annot = (MyAnnotation*)annotation;
UIImageView *egoimageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"defaultPerson"]]; //17.5%
NSString *imageUrl = [NSString stringWithFormat:#"%#%#", CommonImageURL, [friendsProfileImageArray objectAtIndex:annot.tag]]; //9.4%
if ([[UIScreen mainScreen] respondsToSelector:#selector(displayLinkWithTarget:selector:)] &&
([UIScreen mainScreen].scale == 2.0)) {
// Retina display
[egoimageView setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:#"defaultPerson#2x.png"]]; //2.6%
egoimageView.image = [UIImage imageWithCGImage:egoimageView.image.CGImage scale:egoimageView.image.size.width/25 orientation:egoimageView.image.imageOrientation];
} else {
// non-Retina display
[egoimageView setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:#"defaultPerson.png"]]; //14.6%
egoimageView.image = [UIImage imageWithCGImage:egoimageView.image.CGImage scale:egoimageView.image.size.width/25 orientation:egoimageView.image.imageOrientation]; //1.6%
}
[egoimageView sizeToFit];
self.pinView.leftCalloutAccessoryView = egoimageView; //3.1%
[egoimageView release];
self.pinView.canShowCallout=YES;
self.pinView.animatesDrop=YES;
//pin color based on status.....
if ([annot.relationshipStatus intValue]==2 )
self.pinView.pinColor=MKPinAnnotationColorGreen;
else
self.pinView.pinColor=MKPinAnnotationColorPurple; //17.1%
return self.pinView;
}
In this I have mentioned the percentage of memory allocations. If I continuously load the map, the total memory usage increases and the app crashes. How can I properly fix this? I have tried to fix it, but I don't know what more I can do.
Please help, thanks in advance.

Game Center? Xcode

I have been working ver hard on Game center. I have tested so many codes I've lost count.
I would love to know how to automatically submit score as well
here are some codes i have used but i am not sure if this will help
-(IBAction)showleaderboard:(id)sender{
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc]init];
if (leaderboardController !=NULL) {
leaderboardController.category = self.currentLeaderboard;
leaderboardController.timeScope = GKLeaderboardTimeScopeAllTime;
leaderboardController.leaderboardDelegate = self;
[self presentModalViewController:leaderboardController animated:YES];
}
}
-(void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController{
[self dismissModalViewControllerAnimated:YES];
[viewController release];
}
-(IBAction)showAchivementLeaderboard:(id)sender{
GKAchievementViewController *achivements = [[GKAchievementViewController alloc]init];
if (achivements !=NULL) {
achivements.achievementDelegate = self;
[self presentModalViewController:achivements animated:YES];
}
}
-(void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController{
[self dismissModalViewControllerAnimated:YES];
[viewController release];
}
self.currentLeaderboard= kEasyLeaderboardID;
if ([gameCenterManager isGameCenterAvailible]) {
self.gameCenterManager= [[[GameCenterManager alloc] init] autorelease];
[self.gameCenterManager setDelegate:self];
[self.gameCenterManager authenticateLocalUser];
}else{
UIAlertView *openURLAlert = [[ UIAlertView alloc] initWithTitle:#"Game Center turned off" message:#"You are not connected to game center." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[openURLAlert show];
[openURLAlert release];
}
To report a score you need to use GKScore as follows;
GKScore *scoreReporter = [[GKScore alloc] initWithCategory:self.gameCategory.leaderboardString];
scoreReporter.value = score;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil) {
[[KYTGlobals instance] storeScore:score forCategory:self.gameCategory.leaderboardString];
}
}];
The above code allocates and inits a GKScore object using the identifier that you have already set up on game center for the category that you want to report a score for. You update the value for the score and then use reportScoreWithCompletionHandler making sure to test for error so that you can archive the score and report it later.

Resources