Why does my NSUserActivity not show up in the Shortcuts app? - ios

I've defined 3 different NSUserActivitys in my iOS app to allow shortcuts to launch my app in different views. These worked just fine.
For example:
userActivityGo = [[NSUserActivity alloc] initWithActivityType:SIRI_MAIN_ACTIVITY_ID];
userActivityGo.title = #"Launch App";
userActivityGo.eligibleForPrediction = YES;
userActivityGo.eligibleForSearch = YES;
userActivityGo.userInfo = #{#"action" : #"go"};
userActivityGo.requiredUserInfoKeys = [NSSet setWithArray:userActivityGo.userInfo.allKeys];
self.userActivity = userActivityGo;
Recently (maybe due to iOS recent updates?) I've noticed these shortcuts are missing from the Shortcuts app.
When I enter the "apps" section in Shortcuts, my app is not listed there, but I can still see my predefined shortcuts and see them under "Siri Suggestions".
I did not implement intents since I don't have any special UI or input I need from the user, but as I've already said - it worked before.
Were there any related changes that could cause this?

Related

Is there a shortcut suggestions limit on iOS Shortcuts App?

I've created an intent for Apple Shortcuts app and everything works fine, but not all my shortcut suggestions are visible.
I've noticed that a maximum of 30 items are shown. Is there a limit?
Here how I set the suggestions:
var suggestions = [INShortcut]()
for exampleItem in exampleItems {
suggestions.append(INShortcut(intent: exampleItem.getIntent())!)
}
INVoiceShortcutCenter.shared.setShortcutSuggestions(suggestions)

iOS Document Sharing: "Save to Dropbox" always fails

Posting after finding answer
After "rubber duck debugging" this answer a bunch, I finally came across the correct answer on a question that appears to me to be unrelated. I think this question (and its answer) are still relevant, so I'm posting the question and will post my own answer to hopefully help others like me.
I am creating a PDF in my iOS app that I would like to allow the user to export. For the purposes of this testing, I'm trying to save it to my personal Dropbox on a physical device.
I have turned on iTunes file sharing, and I can verify that the PDF file is being generated correctly, and when I copy it off of my device (iPad Pro Gen. 2 running iOS 11), I can open the PDF and it has the expected content and appearance.
I am able to get the document pop-up to display correctly, and I have options to share via:
Line 1: AirDrop
Line 2: Message, Mail, Add to Notes, (Facebook) Messenger, etc.
Line 3: Copy, Print, Save to Files, Save to Dropbox, etc.
No matter what I try to select (Save to Dropbox is the one I want to solve, but the issue seems universal), it fails. Of note, when I click Save to Dropbox, I do see the Dropbox panel display, but there is immediately a modal over top of the Save to Dropbox modal that says, "An unknown error occurred."
I have tried to look around and see how to get more information about this error, but I'm stumped. I'm not sure if it's correlated, but I get this message in the console:
[AXRun-PID] Client requesting unsuspension of PID:813 Name:<redacted>
Trying to google that error has proved unfruitful.
Here's the code where I generate the PDF and show the menu:
#pragma mark • Sharing Methods
- (void)showShareMenu {
NSArray *bookList = [BookManager bookList];
NSURL *pdfUrl = [PdfGenerator generatePdfFromBooks:bookList];
UIDocumentInteractionController *vc = [[UIDocumentInteractionController alloc] init];
vc.name = #"Booklet.pdf";
vc.URL = pdfUrl;
vc.UTI = #"com.adobe.pdf";
[vc presentOptionsMenuFromBarButtonItem:self.navigationItem.leftBarButtonItem animated:YES];
}
I've tried using UIDocumentInteractionController *vc = [UIDocumentInteractionController interactionControllerWithURL:pdfUrl]; instead of the one above, but the results are the same.
I tried making self the delegate of vc and then tried to implement the following methods:
- (void)documentInteractionController:(UIDocumentInteractionController *)controller
willBeginSendingToApplication:(nullable NSString *)application;
- (void)documentInteractionController:(UIDocumentInteractionController *)controller
didEndSendingToApplication:(nullable NSString *)application;
Neither of those methods ever fired.
Interestingly, though I think I've supplied the file name correctly based on what I've read, the name in the File textbook in the Save to Dropbox modal is a current timestamp (e.g., File Oct 28, 11 12 22 PM). The Dropbox modal stays up until I click "OK" on the "An unknown error occurred" modal, and then disappears immediately.
It seems like I'm somehow not providing the right information, but I'm not sure how. It seems like there ought to be a delegate method to indicate an error to me, but I don't see anything like that in the docs. (It is late, and I have been looking at this for hours, including reading several related tutorials, so I could have missed something obvious.)
I came across this answer as an example question while asking this current question.
It doesn't really ask the same question I have, nor did that user have the same error outputs I did. But, the linked answer did work for me, too.
The problem I had in the code above was that I was not keeping the UIDocumentInteractionController around after I created it. Adding a private property fixed this issue. So, the following code now works:
#pragma mark • Sharing Methods
- (void)showShareMenu {
NSArray *bookList = [BookManager bookList];
NSURL *pdfUrl = [PdfGenerator generatePdfFromBooks:bookList];
self.docController = [UIDocumentInteractionController interactionControllerWithURL:pdfUrl];
self.docController.name = #"Booklet.pdf";
self.docController.UTI = #"com.adobe.pdf";
[self.docController presentOptionsMenuFromBarButtonItem:self.navigationItem.leftBarButtonItem animated:YES];
}

add stamp annotation using PSPDFKit iOS objective-c

I am using PSPDFKit framework, and I am unable to add stamp annotation, using this I have implemented following:
[pdfController.annotationStateManager toggleState:PSPDFAnnotationStringStamp];
NSMutableArray<PSPDFStampAnnotation *> *defaultStamps = [NSMutableArray array];
for (NSString *stampSubject in #[#"Great!", #"Stamp", #"Like"]) {
PSPDFStampAnnotation *stamp = [[PSPDFStampAnnotation alloc] initWithSubject:stampSubject];
stamp.boundingBox = CGRectMake(0.f, 0.f, 200.f, 70.f);
[defaultStamps addObject:stamp];
}
PSPDFStampAnnotation *imageStamp = [[PSPDFStampAnnotation alloc] init];
imageStamp.image = [UIImage imageNamed:#"abc.jpg"];
imageStamp.boundingBox = CGRectMake(0.f, 0.f, imageStamp.image.size.width/4.f, imageStamp.image.size.height/4.f);
[defaultStamps addObject:imageStamp];
[PSPDFStampViewController setDefaultStampAnnotations:defaultStamps];
but I have no output.
Peter here, Founder and CEO of PSPDFKit, the PDF SDK for iOS, Android, Web, macOS and (soon) Windows. The best way to reach our support is reaching out directly to our support page. Support is part of your license subscription.
You're setting default stamps for the PSPDFStampViewController. Can you post a screenshot how things look? You're changing the default here (APPROVED, REJECTED and so on and replacing this with your own images, which is valid and works.)
Note that you only need to call this once and it needs to be called before you switch/toggle the stamp mode, so your current code will not work.
Please also make sure you use the latest version so we can rule out any old bugs or incompatibilities. As of writing this, it's Xcode 8.3 and PSPDFKit 6.6 (click for release blog post).
Stamps only show up if you have the annotation component licensed - if you ping us on support my team can check what components you have to make sure that's not the problem here.
If you're just trying to programmatically add annotations via our framework, check out this guide article instead.

Google Places API for IOS does not set localized language

In my app I need user to pick a place using Google places. I call google place picker like so:
GMSPlacePicker * placePicker = [[GMSPlacePicker alloc] initWithConfig:config];
GMSPlacesClient * placesClient = [GMSPlacesClient sharedClient];
[placePicker pickPlaceWithCallback:^(GMSPlace *place, NSError *error) {...}];
My problem is, that presented picking View has English language set instead of my localized language (Slovak). I have read that it is supposed to find localization by itself?
what i did was to changing the default language in my app info.plist
Localization native development region to = "your language prefix goes here"
this changed my app localization and also changed the Google Place Picker to the the preferred language.
my app also needs to be from left to right but my language is right to left so i also forced the app to "left to right"
in my app delegate :
UIView.appearance().semanticContentAttribute = UISemanticContentAttribute.forceLeftToRight
take for consideration "semanticContentAttribute" supported only from ios 9 and above.
i hope this helps anyone struggling with this issue.

UIDocumentInteractionController presentOptionsMenuFromBarButtonItem error in ios8- Unknown activity items supplied

UIDocumentInteractionController presentOptionsMenuFromBarButtonItem gives me a console error in ios8 hardware (and not on 7.1 hardware or earlier):
Unknown activity items supplied: (
{
"com.adobe.pdf" = ;
},
""
)
In my official App Store version of my app, the app crashes at this point. When I compile and run on my iPad it just gives the error but does not crash.
My code:
In the .h:
UIDocumentInteractionController *docInteractionController;
In the .m:
self.docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
self.docInteractionController.delegate = self;
//UIBarButtonItem *element is an element in my toolbar
[self.docInteractionController presentOptionsMenuFromBarButtonItem:element animated:YES];
If I do a NSLog of docInteractionController.UTI I see "com.adobe.pdf" at the console, so the UTI is being recognized properly.
I can get around the "Unknown activity items" by using presentOpenInMenuFromBarButtonItem instead of presentOptionsMenuFromBarButtonItem for the UIDocumentInteractionController call, but I want to show the user the print and email options as well, not only the external app opening options.
Tested on iPad version 8.0.2. Xcode version 6.0.1, deployment target 6.0 (also tested with deployment target 8.0). All objective-c. Running on iPad version 7.1 does not produce the error.
See radar: http://openradar.appspot.com/radar?id=5800473659441152
As noted you can use presentOpenInMenu instead of presentOptionsMenu. You will loose the mail option but you can do it yourself with MFMailComposeViewController with a dedicated mail button.
Or use UIActivityViewController with an "Open In" activity item.
Or just a UIActivityViewController without an "Open In" activity item if that is enough
Or do presentOptionsMenu on iOS7 runtime and UIActivityViewController on iOS8+ runtime (where share extensions exist)
For people not wanting to use UIActivityViewController because the document controller is what we want (all actions show up): you can get around the crash by retaining the UIDocumentInteractionController, e.g. by assigning it to a property and releasing when the document interaction finishes:
- (void)share:(id)sender
{
self.documentInteraction = [UIDocumentInteractionController interactionControllerWithURL:_shareURL];
_documentInteraction.delegate = self;
_documentInteraction.name = self.title;
[_documentInteraction presentOptionsMenuFromBarButtonItem:_actionItem animated:YES];
}
- (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller
{
if (controller == _documentInteraction) {
self.documentInteraction = nil;
}
}
The log will still show up, at least in debug, haven't checked with a release build. But it all works.
This solved the problem for me:
dispatch_async(dispatch_get_main_queue(), ^() {
[_docController presentOptionsMenuFromRect:button.bounds inView:button animated:YES];
});
I was getting the same console logs, but only in debug builds. Try creating a release build and you should see it still prints the "Unknown activity items supplied" error, but without the entire contents of the file.

Resources