IOS 8 Addressbook kABPersonEmailProperty - ios8

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);
}

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.

CKSMSComposeRemoteViewController timed out waiting for fence barrier from com.apple.mobilesms.compose

Ok, so sendSMS worked fine before on ios7 and below. However, on ios8 the sendSMS function just fails with the error in the title of the question. I am getting a warning here (after trying to resolve by changing NSArray to NSString using other stack overflow questions): Incompatible pointer types assigning to 'NSArray *' from 'NSString *' for controller.recipients = recipients; It is returning a result of MessageComposeResultCancelled.
if (ABMultiValueGetCount(phoneNumbers) > 0) {
phone = (__bridge_transfer NSString*)
ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
[self sendSMS:#"Play me on PokerBuddies.
Download the app at: https://itunes.apple.com/us/app /poker-buddies/id404168013?mt=8"
recipientList:[NSString stringWithFormat:phone, nil]];
} else {
phone = #"[None]";
}
- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSString *)recipients{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText]){
controller.body = bodyOfMessage;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
[self presentViewController:controller animated:YES completion:nil];
NSLog(#"Send SMS");
}
}
I have same problem like MessageComposeController timeout issue .
I solved it by doing this.
You have to create instance variable of MFMessageComposeViewController and when you are going to present message controller you have to check if instance object is already created then do it nil and initialize that object again.So this error "CKSMSComposeRemoteViewController timed out waiting for fence barrier from com.apple.mobilesms.compose" will not come and controller open exactly.
if ([MFMessageComposeViewController canSendText]) {
if (messageComposer) {
messageComposer = nil;
messageComposer = [[MFMessageComposeViewController alloc]init];
}
messageComposer.recipients = arrPhoneNumber;
messageComposer.messageComposeDelegate = self;
messageComposer.body = #"Your text";
isMessageComposeAppear = 1;
[self presentViewController:messageComposer animated:YES completion:nil];
}

How to present a semi-transparent (half-cut) viewcontroller in iOS 8

in iOS 7 there is no problem for this method:
_rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
[_rootViewController presentViewController:self animated:NO completion:nil];
But in iOS 8 it did nothing.How to solve it? Is it a Bug for iOS 8?
My answer is more simple, below code. This works in iOS8 (XCode6 GM seed).
HogeViewController *vc = [[HogeViewController alloc] init];
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:vc animated:NO completion:nil];
Note this workaround was needed on xcode6_beta7. The lastest xcode6
has the UIModalPresentationOver* styles fixed. So, I'm just assigning them to myModalViewController.modalPresentationStyle and now it works ok.
Finally made it work in iOS 8 after reading the UIPresentationController help and this post
appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
MyModalController *myModalController = [[MyModalController alloc] initWithNibName:#"MyModalController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myModalController];
navController.modalPresentationStyle = UIModalPresentationCustom;
navController.transitioningDelegate = myModalController;
[self.navigationController presentViewController:navController animated:YES completion:nil];
You can make the modal view controller inherit from UIViewControllerTransitioningDelegate
#interface MyModalController : UIViewController <UIViewControllerTransitioningDelegate>
and override presentationControllerForPresentedViewController:...
-(UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented presentingViewController:(UIViewController *)presenting sourceViewController:(UIViewController *)source
{
if (presented == self) {
return [[TransparentPresentationController alloc] initWithPresentedViewController:presented presentingViewController:presenting];
} else {
return nil;
}
}
returning an instance of TransparentPresentationController which inherits from UIPresentationController
#interface TransparentPresentationController : UIPresentationController
and overrides shouldRemovePresentersView
- (BOOL) shouldRemovePresentersView {
return NO;
}

IAP doesn't work on Real iPad

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..

xcode iOS6 orientation landscape

I see a lot of questions about this subject but am unable to find a solution to the problem I am experiencing. I have created an iPad app that should be Landscape only - it works fine when ran on any os prior to iOS6 but on iOS6 the app opens in portrait view. This screenshot shows what I mean (sorry not a great explanation) http://s1342.beta.photobucket.com/user/designedbyria/media/ScreenShot2012-11-02at122113.png.html
I'm guessing the problem is somewhere in the below code, but I can't be sure. I have set the supported Interface Orientations to Landscape Left and Landscape Right only - but this has not worked. I have also taken a look at the questions here with no luck..
I am using xcode and cordova/phonegap
Interface orientation in iOS 6.0
Set orientation to landscape mode in xcode 4.5 GM IOS 6
iOS 6 apps - how to deal with iPhone 5 screen size?
Thanks in Advance!
/**
* This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up)
/
- (BOOL) application:(UIApplication)application didFinishLaunchingWithOptions: (NSDictionary*)launchOptions {
NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
NSString* invokeString = nil;
if (url && [url isKindOfClass:[NSURL class]]) {
invokeString = [url absoluteString]; NSLog(#"iwill launchOptions = %#", url);
}
CGRect screenBounds = [[UIScreen mainScreen] bounds];
self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
self.window.autoresizesSubviews = YES;
CGRect viewBounds = [[UIScreen mainScreen] applicationFrame];
self.viewController = [[[MainViewController alloc] init] autorelease];
self.viewController.useSplashScreen = YES;
self.viewController.wwwFolderName = #"www";
self.viewController.startPage = #"index.html";
self.viewController.invokeString = invokeString;
self.viewController.view.frame = viewBounds;
// check whether the current orientation is supported: if it is, keep it, rather than forcing a rotation
BOOL forceStartupRotation = YES;
UIDeviceOrientation curDevOrientation = [[UIDevice currentDevice] orientation];
if (UIDeviceOrientationUnknown == UIInterfaceOrientationLandscapeLeft) {
// UIDevice isn't firing orientation notifications yet… go look at the status bar
curDevOrientation = (UIDeviceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
}
if (UIDeviceOrientationIsValidInterfaceOrientation(curDevOrientation)) {
for (NSNumber *orient in self.viewController.supportedOrientations) {
if ([orient intValue] == curDevOrientation) {
forceStartupRotation = YES;
break;
}
}
}
if (forceStartupRotation) {
NSLog(#"supportedOrientations: %#", self.viewController.supportedOrientations);
// The first item in the supportedOrientations array is the start orientation (guaranteed to be at least Portrait)
UIInterfaceOrientation newOrient = [[self.viewController.supportedOrientations objectAtIndex:0]
intValue];
NSLog(#"AppDelegate forcing status bar to: %d from: %d", newOrient, curDevOrientation);
[[UIApplication sharedApplication] setStatusBarOrientation:newOrient];
}
[self.window addSubview:self.viewController.view];
[self.window makeKeyAndVisible];
return YES; }
I had the same problem (but not using cordova/phonegap).
You have to set your view controller as a RootViewController in your appDelegate instead of just adding as a subview.
Replace in you appdelegate:
[self.window addSubview:self.viewController.view];
[self.window makeKeyAndVisible];
By
[self.window setRootViewController:self.viewController];
[self.window makeKeyAndVisible];
You can use the delegate
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
Using this delegate and the application will be present in Landscape mode or any desired orientation mode.
Try it.

Resources