Cannot dismiss email sheet invoked from UIDocumentInteractionController in iOS 8 - ios

I've got a very simple test app which contains nothing but the following code, attached to a UIButton:
- (IBAction)buttonUp:(id)sender {
// Build file path
NSString* filePath = [[NSBundle mainBundle] pathForResource:#"testfile"
ofType:#"txt"];
NSURL *url = [NSURL fileURLWithPath:filePath];
m_interactionController = [UIDocumentInteractionController interactionControllerWithURL:url];
[m_interactionController presentOptionsMenuFromRect:CGRectMake(200, 200, 100, 100)
inView:[self view]
animated:YES];
}
This builds with no issues, and running under iOS 7 (on a 4th generation iPad: A1458), this code works fine.
The problem is that, in iOS 8 Beta 5, if the user selects "Mail" from the UIDocumentInteractionController, then the email sheet that is displayed can never be dismissed. Tapping Send does indeed send the mail, but the email sheet continues to be displayed. Tapping on Cancel and electing to either delete or save the draft has no effect.
The problem occurs when the test app is built using Xcode 5.1.1. However, if the app is built with the Xcode 6 GM, then problem does not occur, and the code works fine.
Is there anything wrong with the code above?

For us, the problem did not occur in the final released version of iOS 8.
I had posted it to Radar, and it was closed as a duplicate (with the status of the duplicate being "Open"), so presumably it was a bug in the prerelease versions of iOS 8.

Related

your app loads indefinitely upon launch

I have an app which works fine on below devices.
iPhone 4s (iOS 7.1)
iPhone 5 (iOS 9.1)
iPhone 6 (iOS 9.1)
However app is rejecting saying below rejection.
We discovered one or more bugs in your app when reviewed on iPad and iPhone running iOS 9.1 on both Wi-Fi and cellular networks.
App did not load its contents, did not load beyond the flash screen.
However when I run this from my side, its working fine but it has problem at Apple end only. I don't know how can app run at my end and its giving problem at Apple end only? I tried to upload with iOS 8.4, but still Apple reply still we can't go beyond splash screen.
Did anyone face such issue OR does anyone point me where I can be wrong?
I have uploaded 6 builds and all are rejected saying same reason.
Note: Same app was working fine earlier (before iOS 9.1 release), but when I try to upload now, it is giving this error.
The biggest challenge for me is, I don't know what is the problem, but I need to FIX this problem
Edit 1
I have first screen as language screen where I have animation of images.
animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1080, 1920)];
animationImageView.hidden = NO;
animationImageView.animationImages = mArray;
animationImageView.animationDuration = 1.5;
animationImageView.animationRepeatCount = 1;
[self.view addSubview:animationImageView];
[animationImageView startAnimating];
After testing on testflight, I found a problem.
If I open the app after clicking app icon, it was working fine.
The problem comes when I click Open button from testflight
When I click Open button, launchOptions in AppDelegate was not nil, so the code in push was going wrong and internally it was crashing but still app was hanged at splash screen (not sure why though)
Below is what I have when I print launchOptions in AppDelegate didFinishLaunchingWithOptions
launchOptions==={
UIApplicationLaunchOptionsSourceApplicationKey = "com.apple.TestFlight";
}
So I changed my code to below and all is working perfectly.
NSLog(#"launchOptions===%#", launchOptions);
if (launchOptions!=nil) {
NSMutableDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
NSLog(#"userInfo===%#", userInfo);
NSLog(#"userInfo===%d", userInfo.count);
if (userInfo.count>=1) {
// here is my code on what to do if i click on push
}
}
Do let me know if someone is not clear
It was crashing saying below
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument'
So I feel problem was at line below.
NSString *badge =[[NSString alloc] initWithFormat:#"%#", [apsInfo objectForKey:#"badge"]];
But after putting above condition, all was working fine.
Did you test using "Run" from Xcode, or using Test Flight? Test Flight gets you the app in the same environment as Apple gets it, while running directly from Xcode may yield different results (different push notification environment, possibly different compilation options...).
Also, do you have access to the logs of the server that the app queries? If so, have you checked them to see what happens when Apple try to use the app? Is the query correctly formed? Was there an error (status code different from 200, or in the error log)?
What kind of request does your app perform? Is it a regular http(s) request? Or are you using an unusual protocol which may be blocked somehow?
I suppose the server queried is fully reachable from the Internet (i.e. you did not put a server that is only accessible on your local network)?
You should add error handling in your code, to test the result of requests and display information about it, so that if there's an error when they test it, at least they can report what the error is.

PhoneGap error handling for iOS App

I have an iOS app designed in PhoneGap. The problem is that the app is crashing during my navigation through it. The app is quite big with lots of videos, but sadly I am unable to locate what instigates the error.
What I did was:
Safari iPad Inspect element. There are no errors there. I have removed all of them but app still crashes without any warning.
As mentioned here, I created error.html and added these lines in MainViewController.m:
(void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
{
[theWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"error" ofType:#"html" inDirectory:#"www"] isDirectory:NO]]];
}
Unfortunately, neither approach worked. Any idea what direction should I go?
You can use an error tracking service that tracks JavaScript errors to get information on your errors.
Atatus is one such service, that works with Cordova/PhoneGap.

Failed to open Apple Pay sheet on iPhone 6

I want to make an example project that open an Apple Pay sheet when user clicks on the 'Pay with Apple Pay' button on my app.
I test my app on an iPhone 6 with iOs version 8.1 (which contains Apple Pay) and Xcode 6.1 GM. Both of them have not been officially released yet.
I followed the tutorial on this page. And this is my code for handling the on-click event of 'Pay with Apple Pay' button:
PKPaymentRequest *request = [PKPaymentRequest new];
// Must be configured in Apple Developer Member Center
// Doesn't seem like the functionality is there yet
request.merchantIdentifier = #"my.valid.merchant.identifier";
request.countryCode = #"US";
request.currencyCode = #"USD";
// Let's go!
// if (![PKPaymentAuthorizationViewController canMakePayments]) return;
PKPaymentAuthorizationViewController *authVC = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];
authVC.delegate = self;
[self presentViewController:authVC animated:YES completion:nil];
Clicking on the 'Pay with Apple Pay' button, I got this error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target
When checking the PKPaymentAuthorizationViewController canMakePayments], it returns false.
I'm not sure about the reason of my error is of the iPhone's setting or my code.
Does someone have the experience with Apple Pay? Please help me. Thank you so much.
I test my app on an iPhone 6 with iOs version 8.1 (which contains Apple Pay)
No, the most recent beta (iOS 8.1 Beta 2) does not contain Apple Pay. There's obviously some stuff in there under the hood as they're working on it, but it's not intended to work for developers yet.
This is why [PKPaymentAuthorizationViewController canMakePayments] returns NO and authVC is nil. Apple Pay is also not available in Settings, nor is it mentioned in the release notes.

iOS 7 UIWebView not rendering

I'm porting my app to iOS 7 and I have a problem with UIWebView in iOS 7.
I load local html string in it with this code:
NSURL *baseURL = [NSURL fileURLWithPath: DOCUMENTS_DIRECTORY];
[self.descWebView loadHTMLString:html baseURL:baseURL];
It works perfectly on iOS 6 and prior but on iOS 7 it doesn't rendering and the UIWebView is still white. And this message appears in console:
void SendDelegateMessage(NSInvocation *): delegate
(webView:decidePolicyForNavigationAction:request:frame:decisionListener:)
failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
Thanks for your replies.
As mentioned by #zaplitny, I had to update Crittercism to the latest version (4.1.0) for this problem to go away.
There was a problem with older version of the Crittercism library which caused this. As others have alluded to in comments, this bug was fixed in the 4.3.1 version of the Crittercism SDK.
https://app.crittercism.com/downloads/release_notes/ios/4.3.1 :
fix: Workaround for apps experiencing UIWebViews failing to load data
on first launch when running on iOS 7. This only occurs in apps that
subclass UIWebView, and Crittercism has filed a bug report with Apple.
Note - Be aware that while your application may not directly subclass
UIWebView, this is done in many common 3rd party libraries such as the
Google AdMob and Millenial Media SDKs.
For those of us who updated Crittercism to the version 4.1.2 hoping that it would solve the issue but it didn't. I can offer quite an ugly but simple solution: create and initialize UIWebView before calling [Crittercism enableWithAppID:#"***...***"];
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
...
UIWebView* fakeWebView = [[[UIWebView alloc] initWithFrame:CGRectMake(-1, -1, 1, 1)] autorelease];
[fakeWebView loadHTMLString:#"<!DOCTYPE HTML><html><body>I need Crittercism</body></html>" baseURL:nil];
[mainViewController.view addSubview:fakeWebView];
[Crittercism enableWithAppID:#"***...***"];
...
}
This trick allowed me not only to get rid of a described problem, but also slightly speed up the first initialization of a real UIWebView.
I had this error appearing trying to display admob ads, when ever crittercism was enabled I would get that error in the logs, incidentally the ads were not displaying either.
To fix it, I disabled crittercism instrumentation, this might not be an option for everyone.
[Crittercism enableWithAppID:#"your_app_id" andDelegate:nil andURLFilters:nil disableInstrumentation:YES];
If not simply creating a webview (You don't need to add it as a subview) as suggested by others seems to work for me as well.
[[UIWebView alloc] initWithFrame:CGRectMake(-1, -1, 1, 1)]
[Crittercism enableWithAppID:#"your_app_id"];
Try product --> clean. It can't hurt. When you run an app it will only replace/compile the files that changed. Some times the xCode bugs up and doesn't compile a changed file. Product clean deletes old versions of the compiled code so next time you build it will have been all from the last compile. Again you have nothing to lose by doing it.
I am seeing the same problem you are. I have tried:
moving the load request from the viewDidLoad to the viewWillAppear and viewDidAppear, this did not help anything
tried reloading the webview after the load request was made. still nothing
tried changing the URL creation from URLWithString to fileURLWithPath and still nothing
What is even more strange is that none of the delegate methods fire when the page doesnt load. it is almost as if the web view doesnt even attempt to load the page. Yet, like you said, if you close the app from the multitask view and reopen it, everything works fine.
were you able to figure out a way around this or found a solution?
I had similar issues with my PhoneGap application on IOS7, i had to Redraw the UI of the page on "viewDidAppear" or "Pageshow" using the below code and this worked for me.
$(".cls_div_page_content").redraw();
jQuery.fn.redraw = function() {
return this.hide(0, function(){$(this).show()});
};
many times this error can come in case u are using something that is not available in that particular iOS version..
for example
NSString *test=#"test this";
[test containsString:#"test"];
use of containsString in iOS 7.1 will give you the same following error, but it will work fine in iOS 8.0,
void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:)
failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
I ran into this issue too. It seems the problem is caused when certain 3rd party libraries are linked, but I am not even sure exactly which one was responsible in my case. I didn't have Crittercism in my app.
What fixed it for me was the suggestion I found here on Apple's Dev Forum to instantiate a UIWebView early.
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// In a severe case of WTF: some 3rd party libs (exact culprit unknown) can cause webviews to stop
// showing anything on iOS 7, and instead have console warnings every 10 seconds that look like:
// void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
// Just instantiating an UIWebView before any of the 3rd party libs kick in is enough to fix it.
// Don't know why, but it works.
if (SYSTEM_VERSION_LESS_THAN(#"8.0")) {
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
webView.delegate = nil; // Do something with webView to silence warning
}
return YES;
}
For those who are using Parse SDK with the 1.6.x version under iOS7/iOS8 and subclass UIWebView, same problem will appear if you are using PFInstallation saveInBackground method.
Solution is to delay call saveInBackground, e.g.:
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3.f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[currentInstallation saveInBackground];
});

iOS, url schemes for app store both for specified developer's apps and for his concrete app to update in iOS 6?

This question was already answered but in iOS 6 all these solutions doesn't work.
My current solutions sometimes doesn't work too:
https://itunes.apple.com/us/artist/developer_name/developer_id
https://itunes.apple.com/us/app/app_name/app_id
the problem is in iOS 6.0.1, but no error with iOS 6.1
This works on my end (Xcode 5 - iOS 7 - Device!):
For the app itself:
itms-apps://itunes.apple.com/app/idYOUR_APP_ID
Code snippet (you can just copy& paste it):
#define YOUR_APP_STORE_ID 545174222 // Change this to your app ID
static NSString *const iOS7AppStoreURLFormat = #"itms-apps://itunes.apple.com/app/id%#";
[NSURL URLWithString:[NSString stringWithFormat: iOS7AppStoreURLFormat, YOUR_APP_STORE_ID]]; // Would contain the right link
For the developer you can use this:
https://itunes.apple.com/artist/idYOUR_ARTIST_ID
You can get YOUR_ARTIST_ID from your iTunes Connect or from the link on one of your apps (there is a "View more by this developer" and copy the number after the "id" on the link itself).

Resources