I am a begginer in iOS app development and I would like to launch my app on copy link from another app. added shared extension on click it is displaying popup. But my requirement is it should not display popup and directly open my app on click of my shared extension.
What I did:
1) Added rules in info.plist
<dict>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
Screen short :
Please someone help me to fix this issue. Thanks
Update : After adding below code popup is not coming but my app is not opening
objective C :
- (BOOL)isContentValid {
return YES;
}
#ifdef HIDE_POST_DIALOG
- ( NSArray * ) configurationItems
{
return @[];
}
#endif
- ( void ) didSelectPost
{
#ifdef HIDE_POST_DIALOG
return;
#endif
}
CGFloat m_oldAlpha = 1.0;
#ifdef HIDE_POST_DIALOG
- ( void ) willMoveToParentViewController: ( UIViewController * ) parent
{
m_oldAlpha = [ self.view alpha ];
[ self.view setAlpha: 0.0 ];
}
#endif
#ifdef HIDE_POST_DIALOG
- ( void ) didMoveToParentViewController: ( UIViewController * ) parent
{
// Restore the original transparency:
[ self.view setAlpha: m_oldAlpha ];
}
#endif
#ifdef HIDE_POST_DIALOG
- ( id ) init
{
if ( self = [ super init ] )
{
[ [ NSNotificationCenter defaultCenter ] addObserver: self selector: @selector( keyboardWillShow: ) name: UIKeyboardWillShowNotification object: nil ];
}
return self;
}
#endif
#ifdef HIDE_POST_DIALOG
- ( void ) keyboardWillShow: ( NSNotification * ) note
{
[ self.view endEditing: true ];
}
#endif
Swift :
override func isContentValid() -> Bool {
// Do validation of contentText and/or NSExtensionContext attachments here
return true
}
override func didSelectPost() {
self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
}
override func viewDidAppear(_ animated: Bool) {
self.view.transform = CGAffineTransform(translationX: 0, y: self.view.frame.size.height)
UIView.animate(withDuration: 0.25, animations: { () -> Void in
self.view.transform = .identity
})
}
calling the completion on request from viewDidLoad should be sufficient
override func viewDidLoad() {
super.viewDidLoad()
⋮
// custom logic
⋮
self.extensionContext?.completeRequest(returningItems: [], completionHandler: nil)
}
If someone got any problems how to hide this pop up window, I had the SLComposeServiceViewController type in my VC. Remove this type and add the normal UIViewController and the Pop up Window doesn't pop up anymore.
Make also sure create a new VC in the storyboard and change the initial VC to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With