This question already has answers here:
iOS 9.3 freeze after calling openURL
(2 answers)
Closed 6 years ago.
I am using the share option in my app using UIActivityViewController; it's working fine in iOS 9.2 and Google+ share option is not working in iOS 9.3
To confirm this, I had downloaded other app which has the share option using UIActivityViewController, and the issue is the entire UI of the app is hanging up.
How can I resolve this issue?
Edit 1:
code:
NSURL * URL = [[NSURL alloc]initWithString:#"http://domainName/message.php?"];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:URL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[request setHTTPMethod:#"GET"];
NSString *tempEmailId = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:CURRENT_USER_EMAIL_ID_UD_KEY];
NSString *tempPassword = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:CURRENT_USER_PASSWORD_UD_KEY];
NSString *basicAuthCredentials = [NSString stringWithFormat:#"%#:%#", tempEmailId, tempPassword];
[request setValue:[NSString stringWithFormat:#"Basic %#", AFBase64EncodedStringFromString(basicAuthCredentials)] forHTTPHeaderField: #"Authorization"];
//NSLog(#"request %#\n",request);
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (data != nil) {
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSArray * activityItems = #[responseString];
dispatch_async(dispatch_get_main_queue(), ^{
activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:activities];
[activityViewController setValue:#"Today's Recommendations" forKey:#"subject"];
activityViewController.excludedActivityTypes = #[UIActivityTypePostToFacebook];
[activityViewController setCompletionWithItemsHandler:
^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(#"activityType: %#, returnedItems: %#, activityError: %#", activityType, returnedItems, activityError.userInfo);
if (completed)
{
NSLog(#"The Activity: %# was completed", activityType);
}
else
{
NSLog(#"The Activity: %# was NOT completed", activityType);
}
});
}];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self presentViewController:activityViewController animated:YES completion:nil];
}
//if iPad
else {
activityViewController.modalPresentationStyle = UIModalPresentationPopover;
// activityViewController.popoverPresentationController.sourceView = sender;
activityViewController.popoverPresentationController.sourceView = self.view;
if ([sender isKindOfClass:[UIButton class]]) {
UIButton *btn = (UIButton *)sender;
activityViewController.popoverPresentationController.sourceRect = btn.frame;
}
[self presentViewController:activityViewController animated:YES completion:nil];
}
});
}
}] resume];
NOTE:: Mail, Twitter, and Evernote are working. Only Google+ is hanging up.
Edit 2:: I don't know exactly but I think- its not related to open URL. If it's related then please let me know HOW?
Some JavaScript problems occurred in iOS 9.3. Its clearly mentioned in below article. Its not a code problem, it's an Apple webview problem. Check attached quote and URL for your reference.
iOS 9.3 freezes when clicking a link in an email
One of the most common problems ... affects links in emails. When using iOS 9.3, some people have found that by clicking a link in the Mail email app, the iPhone or iPad will become unresponsive.
A temporary solution is to turn off JavaScript in the Safari app by going to Settings > Safari > Advanced then turn off the toggle next to JavaScript.
This solution isn't ideal, and thankfully Apple has pushed out a new update, iOS 9.3.1 which according to the release notes "fixes an issue that caused apps to be unresponsive after tapping on links in Safari and other apps."
To download and install the update open up Settings and select General then Software Update. You should now be able to turn JavaScript back on and can click on links in emails and other messages without iOS 9.3 freezing.
Reference Link: iOS 9.3 Problems
Related
We are not allowed to use native mail functionality for sending emails.
Hence our native iPad app integrated MSGraph SDK for sending mails along with an attachment. MSGraphSDK used to verify the work user by getting authentication credentials.
NSArray *scopes = [kScopes componentsSeparatedByString:#","];
[self.authProvider connectToGraphWithClientId:kClientId scopes:scopes completion:^(NSError *error) {
if (!error) {
NSLog(#"Authentication successful.");
[self sendMailWithAttachments];
}
}];
From next time onwards, it will directly send the mails without asking work credentials.
[MSGraphClient setAuthenticationProvider:self.authProvider.authProvider];
self.graphClient = [MSGraphClient client];
MSGraphMessage *message = [self getSampleMessage];
MSGraphUserSendMailRequestBuilder *requestBuilder = [[self.graphClient me]sendMailWithMessage:message saveToSentItems:true];
MSGraphUserSendMailRequest *mailRequest = [requestBuilder request];
[mailRequest executeWithCompletion:^(NSDictionary *response, NSError *error) {
if(!error){
}
}];
MSGraph SDK used to direct the authenticated page automatically if users are not authenticated or users authentication was not successful.
Now problem here is, users are trying to authenticate themselves and sending mails on first few times successfully. After that a month later or more, they trying to send the mails using this app. Unfortunately it does not respond anything.
Try Below Code:
NSString *titleEmail = #"Your title";
NSString *msgBody = #"PFA";
NSArray *toRecipents = [NSArray arrayWithObject:#"xyz#gmail.com"];
NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, self.view.bounds, nil);
UIGraphicsBeginPDFPage();
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndPDFContext();
MFMailComposeViewController *mailComposeVC = [[MFMailComposeViewController alloc] init];
mailComposeVC.mailComposeDelegate = self;
[mailComposeVC setSubject:titleEmail];
[mailComposeVC setMessageBody:msgBody isHTML:NO];
[mailComposeVC addAttachmentData:pdfData mimeType:#"application/pdf" fileName:#"MY.pdf"];
[mailComposeVC setToRecipients:toRecipents];
[self presentViewController:mailComposeVC animated:YES completion:NULL];
So I am doing just a basic facebook share inside my app, and it works fine on my devices (iPhone 6 OS 9.1 and iPad air 9.02) but doesn't work on my coworkers iPad Air 2 8.4.1 or iPhone 6 Plus 9.1. Anyone have any clue as to why this would be?
They are signed into facebook in the device settings. They also have the facebook app installed (I don't have the app, just signed in through settings)
Here's the screenshot of my device showing the message to share, the other devices just show the image and no text.
Here's the code I am using to share
- (void)shareTapped {
UIImage *image = self.pictureView.image;
NSString *postText = [NSString stringWithFormat:#"%#\n*%#\n%#\n%#, %# %#", self.event.shortDescription, self.event.eventCode, self.event.address, self.event.city, self.event.state, self.event.zip];
[[UtilitiesObject sharedInstance] shareMessage:postText image:image parentVC:self];
}
- (void)shareMessage:(NSString *)msg image:(UIImage *)image parentVC:(UIViewController *)parentVC {
NSArray *activityItems = #[msg];
if (image) {
activityItems = #[msg, image];
}
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
// Tailor the list of services displayed
activityController.excludedActivityTypes = #[UIActivityTypeAssignToContact,
//UIActivityTypePostToFacebook,
//UIActivityTypePostToTwitter,
//UIActivityTypeMail,
UIActivityTypeMessage,
UIActivityTypeSaveToCameraRoll,
UIActivityTypePrint,
UIActivityTypePostToWeibo,
UIActivityTypeCopyToPasteboard];
activityController.popoverPresentationController.sourceView = parentVC.view;
[activityController setCompletionWithItemsHandler:
^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
if ([activityType isEqualToString: UIActivityTypeMail]) {
NSLog(#"Mail");
}
if ([activityType isEqualToString:UIActivityTypePostToFacebook]) {
NSLog(#"Facebook");
}
if ([activityType isEqualToString:UIActivityTypePostToTwitter]) {
NSLog(#"Twitter");
}
}];
[parentVC presentViewController:activityController animated:YES completion:nil];
}
Facebook's platform policy does not allow apps to prefill the message field. In this case, because you don't have the Facebook app, it's using Apple's share sheet, which allows prefill but is against FB's platform policy. In your friends case, they're likely seeing the Facebook app's share extension, which correctly enforces the policy, and does not allow prefill.
After updating to iOS 8.3 the text is not inserted into the share dialog
i use a standard
UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:applicationActivities];
NSArray *excludeActivities = #[UIActivityTypeAssignToContact];
vc.excludedActivityTypes = excludeActivities;
if (IsUserInterfaceIdiomPad) {
vc.popoverPresentationController.sourceView = self.navigationController.view;
}
[self.navigationController presentViewController:vc animated:YES completion:^{
}];
where the items are a NSString and an NSURL
Looks like Facebook doesn't want the app to pre-propagate the share dialog with text anymore :(
It doesn't have to do anything with the iOS version, but with the build in Facebook App (as the share processes is somehow interlinked with the FB app)
It's stupid and on Android you couldn't do it either (it was disabled longer ago) i hope Facebook reconsiders this as it will lead to fewer shares and some might be willing to drop the share option
Note: if the user doesn't have the FB app installed (he removed it), than the text is added to the status, but i guess that only a small amount of users, but maybe a good reason to still supply text to the share items
NSString *strName= #"Mohit Thatai";
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login
logInWithReadPermissions: #[#"public_profile", #"email"]
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error)
{
NSLog(#"Process error");
}
else if (result.isCancelled)
{
NSLog(#"Cancelled");
}
else
{
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
[content setContentTitle:#"GPS Tracker"];
[content setContentDescription:[NSString stringWithFormat:#"%# shared an interesting link\n This might be interesting to you: GPS Tracker for Kids",strName]];
content.contentURL = [NSURL URLWithString:[NSString stringWithFormat:#"http://gpsphonetrackerkids.com"]];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];
}
}];
When I try to share on Facebook using presentOSIntegratedShareDialogModallyFrom, I can not see the app name. I use the following code:
[FBSettings setDefaultDisplayName:[[FBSettings defaultDisplayName] precomposedStringWithCanonicalMapping]];
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:[arrDetailsOfTour valueForKey:#"WebAddress"]];
params.picture = [NSURL URLWithString:[arrDetailsOfTour objectForKey:#"ImageUrl"]];
params.name = [NSString stringWithFormat:#"%#",[arrDetailsOfTour valueForKey:#"CompanyName"]];
[FBDialogs presentOSIntegratedShareDialogModallyFrom:self initialText:[NSString stringWithFormat:#"%#",[arrDetailsOfTour valueForKey:#"CompanyName"]] image:toursImageView.image url:[NSURL URLWithString:[arrDetailsOfTour valueForKey:#"WebAddress"]] handler:^(FBOSIntegratedShareDialogResult result, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];
but I am not able to see the app name in the post. I have put Facebook Display name in plist, but still it does not show. Please help.
Apple controls the UI for the iOS integrated dialog, and they don't show the app name. The native Facebook Share Dialogs and the web dialogs will.
There are some apps (like the free version of Cut the Rope) that present the App Store page of other apps directly in the app (probably using a modal view controller).
How do I implement this in my own app?
Example from Cut the Rope:
You can use SKStoreProductViewController for this, check out documentation for more detail
if ([SKStoreProductViewController class]) {
NSString *yourAppID = #"";//Give your app id here
NSDictionary *appParameters = #{SKStoreProductParameterITunesItemIdentifier :yourAppID};
SKStoreProductViewController *productViewController = [[SKStoreProductViewController alloc] init];
[productViewController setDelegate:self];
[productViewController loadProductWithParameters:appParameters completionBlock:nil];
[self presentViewController:productViewController animated:YES completion:nil];
}
One can implement a App Store page of any application within their own app by using the SKStoreProductViewController class.
NSString *strURL = #"" //Keep the App store URL here.
if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 6.0)
{
SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];
NSRange range = [strURL rangeOfString:#"/id"];
NSRange rangeID = {range.location + 3, 9};
NSString *strAppID = [strURL substringWithRange:rangeID];
NSLog(#"appid = %#", strAppID);
// Configure View Controller
[storeProductViewController setDelegate:self];
[storeProductViewController loadProductWithParameters:#{SKStoreProductParameterITunesItemIdentifier : strAppID}
completionBlock:^(BOOL result, NSError *error) {
if (error) {
NSLog(#"Error %# with User Info %#.", error, [error userInfo]);
} else {
}
}];
// Present Store Product View Controller
[self presentViewController:storeProductViewController animated:YES completion:nil];
}
The above code also extracts the app ID from the URL.
You can read about it in the class reference.