Triggering a function in one app from another - ios

I have a requirement where I download an invoice in App A. I have a printing App B. The invoice in App A needs to be printed using App B. Is there a way I can achieve this using swift ios?
Both App A and App B belongs to the same development team.

You can not directly call another applications functions however you can launch the other application using a URL scheme (Create a URL scheme to handle printing invoices and the routing required if launched via the scheme) and pass the required information for the invoice to be printed.

Related

Open SwiftUI App from other application, Microsoft Teams, Messenger, WhatsApp, etc

I am developing an SwiftUI App that app involves with creating notes like an usual to-do list app. The exception is that the note must be able to be shared to another users via Microsoft Teams, Messengers and WhatsApp.
Thus, I tend to implement some sort of functionalities to send another user one URL link. Every time the users click on the link from third-party app (WhatsApp, Teams, FB), the link will prompt and navigate users to the app that I developed and installed on their machine. Based on the URL my app will perform specific actions.
How I can do that. My current attempt is to define a customer URL for the SwiftUI app.
Thanks for reading this question, cheers.
You are looking for Custom URL Scheme and Universal Links
From documentation:
Custom URL schemes provide a way to reference resources inside your app. Users tapping a custom URL in an email, for example, launch your app in a specified context. Other apps can also trigger your app to launch with specific context data; for example, a photo library app might display a specified image.
let url = URL(string: "myphotoapp:Vacation?index=1")
UIApplication.shared.open(url!) { (result) in
if result {
// The URL was delivered successfully!
}
}

Multiple iOS apps with single database and single log on

I created multiple apps in android with single database (Content provider) , single log on (which means if i login in one app it should work for all , if I logout from one app it should logout from all other apps) , I have to open one app from another app and every day I have to update all my off line data to server (it should happen particular time on every day ) . Now I am going to port this system (all apps) to iOS , is it possible in iPhone ? And I am not going to submit this apps to app store.
Yes it is possible. You would need to save your database at container url which you can get using:
- (NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier;
The groupIdentifier param needs to be same for all the apps and needs to be configured inside Target->Capabilities->App Groups.
Once you have configured same appGroup for each application, you can use above method to save database at the location, provided by the method. That way the same DB would be accessible to all the apps.
There is NSUserDefaults init methid which takes suitename(appGroup), and creates a shared UserDefaults, which can be used for your single log-on purpose.
- (instancetype)initWithSuiteName:(NSString *)suitename;
Refer:
containerURLForSecurityApplication
NSUserDefaults
You can use AppGroups to share files between your apps. Using AppGroups you can implement a Single Sing-On functionality by storing a Bool in your database that each of your apps have access to that indicates whether the user is currently signed in or not and act accordingly when opening one of your apps.

How to shorten a Firebase Dynamic Link using my own domain name

I'm trying to implement Firebase Dynamic Links in an iOS app. The goal is to have a clean URL for marketing purposes so folks can share links on social media. The idea is folks will share the clean URL that starts with my domain name.
When the app is installed following a click on that link, we want to be able to track who referred the app install by looking at the payload delivered by Firebase. I think this goal is similar to Firebase's use case to convert web users to mobile app users.
An example link I would like to provide for sharing on social media is: http://example.com/my-payload-here
I've tried several cases but I'm not able to get the behavior I'm looking for in any case. Has anyone implemented this successfully before?
Here is my test procedure:
Uninstall the app
Send the link to be tested in an iMessage to myself
Tap the link on my iOS device (not using a simulator)
Install the app from the App Store
Launch the app after download completes by tapping "Open" button in the App Store
Below are my findings:
Short link generated from the Firebase Console (https://xyz.app.goo.gl/ABCD) - Link opens in App Store. I install the app. When I launch the app after installing, the payload is not delivered. If I quit out of the app, go back to the link in iMessage, and launch a second time, the payload is delivered.
Long link identical to the "Long Dynamic Link" from the Firebase console for the link generated in #1 (https://xyz.app.goo.gl/?link=http://example.com/my-payload-here&isi=12345&ibi=com.example.MyApp) - behavior is identical to #1
Short link using my domain (http://example.com/redirect/my-payload-here, configured to 301 redirect to URL in #2) - Opens in App Store. I install. When I launch the app after installing, the payload is not delivered. If I quit out of the app, go back to the link in iMessage, and launch a second time, the link still goes to the App Store.
Some questions I have:
Why isn't the payload delivered on the first launch for cases 1 and 2?
How can we make this launch the app and deliver the payload instead of going to the App Store?
I've also consulted the Firebase flowchart for the deep link in case 2.
Google Firebase team added support for custom subdomains to Dynamic Links.
You can now specify up to five custom page.link subdomains for your Dynamic Links. Short links using these new custom subdomains look like the following example: https://example.page.link/abcXYZ
Firebase Dynamic Link domains assigned on projects couldn't be deleted at this time.( firebase team is working on it.)
You can now whitelist the URL patterns that can be used as a Dynamic Link's deep link (link) or fallback link (ifl, ipfl, afl, ofl). If you define a whitelist, Dynamic Links won't redirect to URLs that don't match a whitelisted pattern.
You can try both of these features in the Firebase console.
This is not currently possible with Firebase. If you need whitelabeled URLs, you either need to build it yourself or use a more powerful link platform like Branch.io (full disclosure: I'm on the Branch team).
To answer your questions specifically:
I have implemented Firebase Dynamic Links in a testbed app and can confirm that linking through installation the first time does work for both long and short URL variants. There is likely something wrong with your AppDelegate config, so we can take a look at that if you want to share code.
Firebase does not support custom domains at this time. In theory (if you can solve the first issue above) you could get this working for first install by using a redirect like you have tried. However, you'll never be able to get it to launch the app with Firebase link data once the app is installed. This is because Universal Links work based on the domain of the link, and don't even request the web destination. Even if you enable Universal Links manually on your own domain, the app will open immediately without ever calling Firebase and the link data will never be set.

Can an app access sqlite table of another? - iPhone iOS

I think it's a dumb question ; anyways, to clear any possible assumption, I will ask it : I have 2 iOS apps : one free version and another paid version. Say, the user is using the free version, which has some SQLite tables in the device. Now, the user installs the paid version of the App (not an in-App purchase, but a separate paid version) ; now, can this newly installed paid version access the sqlite data of the free app, which is already in the device?
Apps can not directly access the data of other apps. However, in a case like yours, you can write both apps to access a common UIPasteboard. Combined with each app having a custom URL scheme, there is a way to allow you write your free/paid apps so you can transfer the data between the two apps.
Here is an outline of the process:
App A (full verion) looks for custom URL scheme of App B (lite version).
If found show "transfer" button somewhere appropriate.
User taps button in App A
App A launches App B with URL that says "send me your data".
App A exits and App B is launched.
App B handles URL request.
App B packages up its data and puts in a named UIPasteboard (name hardcoded in to App A and App B).
App B launches App A with URL that says "you have data".
App B exist and App A is relaunched.
App A handles URL request.
App A gets data from pasteboard, removes it from pasteboard, installs data into self, and refreshes.
App A informs user transfer is complete.
The paid app should have a custom scheme of something like "myapppaid" and the free version should have a custom scheme of "myappfree".
With it just associated with the app, then no not directly as it only exists within the application sandbox which is available only to the application. If it's available via iCloud then you should be able to, as that's how a few apps have managed 'upgrades' when they've realised new standalone versions.

How to make the app install another app inside them and execute the new installed app in IOS

I need to use the in app purchase server model, where I want the user to buy the the new interactive storybooks for kids and play the book.
I have searched through the net, but was off the luck.
just like -- http://itunes.apple.com/in/app/playtales-kids-interactive/id389523239?mt=8
How to get this work. please help
Thanks a ton.
You can't "install another app" programmatically. What you can do is to open the URL of your second app in iTunes from your application with UIApplication openURL. When you invoke this method with a link in iTunes, the App Store application will automatically open with the information page of your second application. Here the user can purchase it with a simple click.
On the other hand, the link you posted above does not use this approach but downloads/enables some new feature (a new e-book) in the application that was hidden before. I.e. all books were already in the application at the time of download, only they were hidden, or it downloads them from a server via a custom protocol defined by the application.

Resources