I am able to open Register app from my app on iPad by passing amount.
Now, when I cancel this by clicking on X at top left, Register app doesn not open back my app.
Versions :
iOS : 10.1.1
Register App : 4.54.1
Xcode : 8.2
Any suggestions ? What I am missing ?
Code :
if (totalAmount)
{
NSError *error = nil;
SCCMoney *amount = [SCCMoney moneyWithAmountCents:9000 currencyCode:#"USD" error:&error];
if (error)
return;
NSURL *const callbackURL = [NSURL URLWithString:#"myapp-callback://abc"];
SCCAPIRequest *request = [SCCAPIRequest requestWithCallbackURL:callbackURL
amount:amount
userInfoString:#"Info"
merchantID:nil
notes:#"Coffee"
customerID:nil
supportedTenderTypes:SCCAPIRequestTenderTypeAll
clearsDefaultFees:NO
returnAutomaticallyAfterPayment:YES
error:&error];
if (![SCCAPIConnection performRequest:request error:&error])
{
DLog(#"Error with Register Payment");
}
}
Callback URL setup :
Xcode
Square Developer portal
You probably haven't registered myapp-callback://abc for your application.
If you look at the first step on this page:
https://docs.connect.squareup.com/articles/register-api-ios/
You'll need to add a URL scheme for your app to your info.plist like the Hello Charge sample has below, I'm guessing you don't have myapp-callback://abc in there and Square Register is unable to switch back to your app.
OK I got the issue.
URL scheme should be same in info.plist and at developer portal.
In my case it was myapp-callback://abc in info.plist and myapp-callback at developer portal.
Related
// tap photo auth entrance
XCUIElement *collectionView = app.collectionViews.firstMatch;
XCUIElement *authCell = [collectionView.cells elementBoundByIndex:2];
[authCell tap];
// springboard click allow
XCUIApplication *springboard = [[XCUIApplication alloc] initWithBundleIdentifier:#"com.apple.springboard"];
XCUIElement *button = [[springboard.alerts.firstMatch buttons] elementBoundByIndex:1];
BOOL exist = [button waitForExistenceWithTimeout:5];
XCTAssertEqual(exist, YES, #"photo auth alert not exist");
[button tap];
It works fine on my iphone12(iOS15.4), but it not works on another iphone12-Pro(iOS15.4)
error:
*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil (NSInvalidArgumentException)
How should I solve this problem?
Thanks a lot!
Steps working for me :
close the iOS device or simulator
clean the build folder
clear the derived data
then open the iOS Device or simulator
you are good to go
Restarting iOS Device or simulator works for me
I'm trying to reload the icon cache after installing an application through LSApplicationWorkspace. The applications install, but I have to execute "uicache" in mobileterminal to reload the springboard cache. Is there a way I could do this programmatically? The application ISN'T running as root by the way.
At the moment, I have code as follows to reload the springboard icon cache but it doesn't work:
remove("/var/mobile/Library/Caches/com.apple.mobile.installation.plist");
remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-icons");
remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-icons.plist");
remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-smallicons");
remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-smallicons.plist");
remove("/var/mobile/Library/Caches/SpringBoardIconCache");
remove("/var/mobile/Library/Caches/SpringBoardIconCache-small");
remove("/var/mobile/Library/Caches/com.apple.IconsCache");
// find ios 8 version:
NSString *cache_path = #"/var/mobile/Library/Caches/";
NSArray *conts = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:cache_path error:nil];
for (NSString *filefolder in conts) {
if ([filefolder containsString:#"com.apple.LaunchServices"]) {
NSString *newpath = [cache_path stringByAppendingPathComponent:filefolder];
remove([newpath UTF8String]);
}
}
// build the args list
Class __LSApplicationWorkspace = objc_getClass("LSApplicationWorkspace");
[(LSApplicationWorkspace *)[__LSApplicationWorkspace defaultWorkspace] invalidateIconCache:nil];
[(LSApplicationWorkspace *)[__LSApplicationWorkspace defaultWorkspace] registerApplication:[NSURL fileURLWithPath:bundlePath]];
int didNotify = notify_post("com.apple.mobile.application_installed");
NSLog(#"Did Notify: %i",didNotify);
// remove temp.app:
if ([[NSFileManager defaultManager] fileExistsAtPath:bundlePath]) {
[[NSFileManager defaultManager] removeItemAtPath:bundlePath error:nil];
}
I found a temporary solution to my question if anyone is interested. I created an extra application (running as root), that was to be installed separately from the original app. I made this application invisible to the user by adding the following to the Info.plist:
<key>SBAppTags</key>
<array>
<string>hidden</string>
</array>
And used URL Schemes to call the "Reload" function.
Although another option could have been to create a LaunchDaemon or a MobileSubstrate extension. I couldn't find a way of reloading the cache as a "mobile" user though.
i have an application where i am loading large amount of images from database and showing them in my gallery, what i was doing earlier is i was getting photo url (local identifier) from PHAsset and then accessing the image using PHCacheManager, but it slows down my scrolling and also shows lags while updating images in new cell. I was trying to use SDWebImage here by passing the url to the sd_setImageWithURL: method, however i found out that the URL is actually a local identifier which is not supported by the method. Do we have other mechanism where i can use the identifier to load the images faster using SDWebImage or any other framework.
This is my code:
NSURL *photoURL = [NSURL URLWithString:photoPath];
[imageView sd_setImageWithURL:photoURL placeholderImage:defaultImage];
photoPath is the path to my asset "current image to be loaded"
i am getting the url something like:
73F05642-CAE6-49BE-879B-9B00BF15391F/L0/001
Please ask if more information is needed, i am new to iOS and all this stuff. Thanks in advance :)
it's late , but i am posting it so that it will be helpful for others .
SDWebImageManager * manager = [SDWebImageManager sharedManager];
[manager downloadImageWithURL:[NSURL URLWithString:localIdentifier] options:SDWebImageHighPriority targetLocalAssetSize:CGSizeMake(150, 150) progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image) {
imageview.image = image;
}
}];
I have a very strange (& serious) problem.
My app uses a UIDocumentInteractionController to share a PDF document.
When the user selects the "Mail" option in the controller's pop-up the MailCompose window is opened.
But, neither the Send nor Cancel button in this window causes the MailCompose window to be dismissed, meaning the user gets stuck and has to kill the app. The mail does go out though.
Here's the catch:
This happens only in iOS8 (both versions released so far) and only on apps installed via the AppStore. That EXACT same version of the app, when running on my device via USB debugging works fine.
Here's some code:
-(void)sharePDF:(id)sender
{
#try
{
NSURL *fileURL = [NSURL fileURLWithPath:currentFileObject.LocalPath];
if(fileURL)
{
//UIDocumentInteractionController
NSString *newPath;
#try
{
//Create a copy of the file for sharing with a friendly name
if (currentFileObject.isSpecialReport)
{
newPath = [svc saveReport:[NSData dataWithContentsOfURL:fileURL] ToFile:[NSString stringWithFormat:#"%#.pdf", currentFileObject.ReportName]];
}
else
{
newPath = [svc saveReport:[NSData dataWithContentsOfURL:fileURL] ToFile:[NSString stringWithFormat:#"%#.pdf", currentFileObject.PatientFullName]];
}
}
#catch (NSException *exception) {
return;
}
NSURL *newURL = [NSURL fileURLWithPath:newPath];
self.docController = [UIDocumentInteractionController interactionControllerWithURL:newURL];
self.docController.delegate = self;
if (currentFileObject.isSpecialReport)
{
self.docController.name = [NSString stringWithFormat:#"Pathology - %#", currentFileObject.ReportName];
}
else
{
self.docController.name = [NSString stringWithFormat:#"Pathology - %#", currentFileObject.PatientFullName];
}
[self.docController presentOptionsMenuFromBarButtonItem:btnShare animated:YES];
}
}
#catch (NSException *exception) {
return;
}
}
I do not implement any of the delegate methods since non of them are required, I also do not make use of the preview functionality.
What's most puzzling to me is that the app from the AppStore behaves differently than my local one although the code is identical. My next step is to use the new beta developer tools (Test Flight) to re-publish the app, hoping that I can replicate the problem.
EDIT: I found a similar question on SO here: Cannot dismiss email sheet invoked from UIDocumentInteractionController in iOS 8
After reading that post I think it worth mentioning that I submitted the app to the AppStore via XCode 5 (the last version before XCode 6). Can that really be a factor here? Does Apple not use the same version on their side as the version in which the app was originally built?
I think this is a bug in iOS 8, and if it's still not working for you, I don't think Apple are likely to fix it. I'd upgrade to Xcode 6 and see if that fixes it for you. (It did for us, as you've discovered).
Seeing this error message in the logs, though not consistently, around the time that I use SLComposeViewController to open a Twitter or Facebook share sheet. I am not using any new iOS 8 API, just testing existing code on iOS 8. I see others have had this problem and even seen crashes when using other modal view controllers from the Cocoa Touch SDK.
LaunchServices: invalidationHandler called
Are there new precautions to take with SLComposeViewController and UIActivityViewController in iOS 8? Something else to consider?
Add this code after you present your activity view controller:
if ([activityVC respondsToSelector:#selector(popoverPresentationController)])
{
// iOS 8+
UIPopoverPresentationController *presentationController = [activityVC popoverPresentationController];
presentationController.sourceView = sender; // if button or change to self.view.
}
Looking at the developer forums: "That log message does not indicate any error on your part."
I had a similar problem with a UIDocumentInteractionController, where when I tapped outside it to dismiss it, or selected another app to open the document in, it would crash with the "LaunchServices: invalideationHandler called" console message displayed twice (only using iOS 8).
A workaround is to add the call to presentOpenInMenuFromRect:inView:animated to the main queue, i.e.
dispatch_async(dispatch_get_main_queue(), ^() {
[self.documentInteraction presentOpenInMenuFromRect:theRect inView:self.view animated:YES];
});
You may also need to define the sourceRect. I used the following code to display a SLComposeViewController from a tableView.
if ([controller respondsToSelector:#selector(popoverPresentationController)]) {
//get rect for this row in table
CGRect frame = [self.tableView rectForRowAtIndexPath:indexPath];
//convert table row frame to view reference
CGRect frameInView = [self.tableView convertRect:frame toView:self.view];
[controller popoverPresentationController].sourceRect = frameInView;
[controller popoverPresentationController].sourceView = self.view;
}
Regarding the auto-closing (not the crash):
I think it's probably related to the link you are trying to share. I'm seeing the same thing when trying to post music links (Spotify, SoundCloud,...). The same tweet works if I replace the link by a link to some non-media-content. I'll file radar on this to see whether it's intentional...
This gets rid of the Error message for me and works as expected. You have to get rid of the if statement that calls "isAvailableForServiceType:"
It should look like this. Happy coding.
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:#"Great fun to learn iOS programming at appcoda.com!"];
[self presentViewController:tweetSheet animated:YES completion:nil];
if ([tweetSheet respondsToSelector:#selector(popoverPresentationController)])
{
// iOS 8+
UIPopoverPresentationController *presentationController = [tweetSheet popoverPresentationController];
presentationController.sourceView = sender; // if button or change to self.view.
}