Open "Mail App Extension" preferences panel with Swift in macOS - swift

Mail App Extensions were announced by Apple at WWDC21. The implementation is very similar to Safari App Extensions. With the method showPreferencesForExtension(withIdentifier:completionHandler:) of the SFSafariApplication class it is possible to launch Safari and open the preferences panel for a specific Safari app extension.
Example Code:
import SafariServices
SFSafariApplication.showPreferencesForExtension(withIdentifier: "example") { error in
// error handling...
}
In addition, the state of the extension can be checked. This is useful to show the user in the container app if the extension is enabled. You can implement this using the getStateOfSafariExtension(withIdentifier:completionHandler:) method of the SFSafariExtensionManager class.
Example Code:
import SafariServices
SFSafariExtensionManager.getStateOfSafariExtension(withIdentifier: "example") { state, error in
// check state and error handling...
}
Unfortunately, I haven't found any ways to implement this for Mail App Extensions yet. Of course, I know that I can open the Mail App quite easily with NSWorkspace:
if let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.mail") {
NSWorkspace.shared.open(url)
}
...but this is just a workaround and not a solution. I want to open the "Mail App Extension" preferences panel and read the status of the extension. Am I missing an API for this?

Related

Gigya swift sdk login with social providers getting issue: [facebook] can't login with WebView, install related sdk

Gigya.sharedInstance().showScreenSet(with:"Store-RegistrationLogin", viewController: self) { result in
switch result {
case .onLogin(let account):
// onLogin event
print("onLoginaccount-->",account)
case .error(let event):
// error event
print("error-->",event)
case .onAfterValidation(event: let event):
print("onAfterValidation")
case .onCanceled:
print("onCanceled")
}
}
i am using above code Gigya screen set is loaded and Normal registration and login working fine but when i click on the Social providers App crash i am getting below issue
[facebook] can't login with WebView, install related sdk. curently i am using xcode 13.1 and swift 5
Please help me #thanks
Firstable following the instruction from Facebook:
https://developers.facebook.com/docs/ios/getting-started/
once you have it works, following our instructions:
https://sap.github.io/gigya-swift-sdk/GigyaSwift/#facebook
You can find our providers wrappers here:
https://github.com/SAP/gigya-swift-sdk/releases/tag/core%2Fv1.3.1
Do not forget to configurate your provider in your console:
https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/5ff3bc8174da4542a61d03033af4877d.html
Adding Facebook native login to your iOS app is mandatory if you want to login via Facebook. https://sap.github.io/gigya-swift-sdk/GigyaSwift/#facebook

Open any email attachment inside the ios app

I want to open any email attachments with my iOS app. Means from my iOS app I want to open email and if there is any attachments(like pdf), I want to open this attachment with my app.I am able to open email app from my app with the following code
if let mailURL = URL(string: "message:") {
if UIApplication.shared.canOpenURL(mailURL) {
UIApplication.shared.open(mailURL, options: [:], completionHandler: nil)
}
}
After that how to open any attachments inside the iOS app. can any one help me. Can I save the attachments to my documents Directory?
Actually my requirement is from my app I will go to the mail box. If any attachment present there, I have to open it with my app. Not only I want to open it with my app, but also I want to save the file in my documents directory.
You can't tell the Mail app what to do so what you want is not exactly possible.
What you can do is add your app in the "Open In" menu by supporting some file types. So that when the user taps the attachment your app will appear in the list of apps.
You can do that this way:
Add the file types your app can handle. Follow the instructions here: https://developer.apple.com/library/archive/qa/qa1587/_index.html
Once 1. is done add the following function in your AppDelegate:
func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool {
// do what you want with file
}
To save the file in your app's document directory you can see how it's done here:
https://programmingwithswift.com/save-file-to-documents-directory-with-swift/

Send user to page on mobile app when clicking email link

I have just started an Ionic 2 mobile app.
I am setting up an update password process where a user can enter their email, click a "send password update email" button which then emails them a link. They can click that link which takes them to a page where they can update their password.
How do I send them a link in their email that when clicked on will open up the app and take them to a specific page?
Even more complicated is that I have a web app also. So if I'm sending them an email, should I show update password on website and update password on mobile app links? Or should I just add a link to the website?
In order to open the mobile app from a link, you need to integrate a cordova plugin called cordova-plugin-customurlscheme. With this plugin you can register a custom url "protocol" that is unique to your app (eg. myAwesomeApp://register?token=123). After installing the plugin with your custom url, clicking on any link starting with myAwesomeApp:// will open your app and also trigger a function hooked on the window object called handleOpenUrl which accepts the url as param. Inside there you can do your routing, depending on the url param.
let self = this;
(<any>window).handleOpenURL = function handleOpenURL(url) {
setTimeout(() => {
if (url && url.indexOf('\register') !== -1) {
let token = URLHelper.getParameterByName(url, 'token');
self.setAsRoot(ConfirmEmailPage, { activationToken: token });
}
}, 0);
};
As for dealing with your web app, what you could do is the following (this is what I am currently doing):
Host online a page (say www.myAwesomeWebsite.com/register?token=123) that checks to see if the user is coming from a mobile device (iOS or Android more specifically). If so on page load redirect them to your myAwesomeApp://register?token=123 link and have a button saying install app from app store with a link to your mobile app. If the user has the app, the app will be opened by the redirect, if they don't they will get an alert saying link cannot be found or sth and after clicking ok they will see the install App from app store button. If the user is not coming from a mobile device, just redirect them to your web app myAwesomeWebApp.com/register?token=123.
Another option is to use a third party service for deep linking like branch
Hope that helps.
EDIT: Since I posted this answer Ionic team has come with their own plugin for deep linking that kind of simplifies some of the hooking up inside your app. Their detailed blog post can be found here. In essence you install their plugin:
cordova plugin add ionic-plugin-deeplinks --variable URL_SCHEME=ionichats --variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=ionic-hats.com
and then hook to it like so:
import {Component, ViewChild} from '#angular/core';
import {Platform, Nav, ionicBootstrap} from 'ionic-angular';
import {Deeplinks} from 'ionic-native';
import {AboutPage} from './pages/about/about';
import {HatDetailPage} from './pages/hat/hat';
#Component({
template: '<ion-nav [root]="rootPage"></ion-nav>',
})
class MyApp {
#ViewChild(Nav) nav:Nav;
constructor(private _platform: Platform) {}
ngAfterViewInit() {
this._platform.ready().then(() => {
Deeplinks.routeWithNavController(this.nav, {
'/about-us': AboutPage,
'/hats/:hatId': HatDetailPage
});
});
}
});
ionicBootstrap(MyApp);
Note that although this improves the plugin interfacing a bit, it does not change the fact that you have to use some other mechanism to handle deep links in conjunction with your web app.

open Skype in a Swift webview

I want to open Skype in a Swift webview by just using a URL. Similar to something like the URL Scheme's provided by Apple for opening Apple Mail mailTo:// or telephone tel://.
1.) must i use the skype-API or just check if skype is installed with
#IBAction func skypeMe(sender: AnyObject) {
let installed = UIApplication.sharedApplication().canOpenURL(NSURL(string: "skype:")!)
if installed {
UIApplication.sharedApplication().openURL(NSURL(string: "skype:echo123?call")!)
} else {
UIApplication.sharedApplication().openURL(NSURL(string: "https://itunes.apple.com/in/app/skype/id304878510?mt=8")!)
}
}
2.) how must i call this? (skype:username?call)
3.) my skype-login should be called automatically
4.) i want to choose the addressee
Is that possible?
This link could help.
UIApplication.sharedApplication().openURL launches skype automatically
Try openURL(NSURL(string: "skype:")!) It may launch skype,
where you could
choose the addresses. Or may not launch.

How to get the fileURL when an ACTIVE app is opened from other apps

I have already implemented DocumentTypes in the info.plist, and the applicationDidFinishedLaunchingWithOptions just works fine, because I can get the fileURL from the option dictionary.
My question is: when I opened my app and send it to background, and open other apps such as Safari and "Open in" a file, my app become active and is there anyway to get the fileURL from anyplace? I found that applicationDidBecomeActive has no userInfo.
You need to override application:handleOpenURL: or application:openURL:sourceApplication:annotation: in your UIApplicationDelegate to get this information.