I am using the following line in my AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Database.database().isPersistenceEnabled = true
return true
}
Is this all I need to add to make my ReactJS app available offline? When I compile and run and test through Testflight - I turn off WIFI and use Airplane Mode and my app just returns a blank screen ... do I have to enable something else?
The Database.database().isPersistenceEnabled = true only ensures that data that you app has recently loaded while online is also available when you call the same API next time while offline.
If the app itself doesn't load, it is unrelated to this API call and you'll want to look at how to make a React app available while offline.
Related
I'm a bit lost about AppTrackingTransparency and how to initialize some SDKs (like FB or Firebase), especially after a user first install of the app.
I don't want to show the user the app tracking transparency popup IMMEDIATELY after he installs the app because it feels too aggressive. I prefer him to go through a few steps before.
However, I know that I need to initialize some SDKs in the AppDelegate's didFinishLaunching method, i.e.:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Firebase
FirebaseApp.configure()
// FB
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
if #available(iOS 14, *) {
Settings.setAdvertiserTrackingEnabled(true)
}
return true
}
What I'm afraid of is that initializing these SDKs before showing the ATTrackingManager.requestTrackingAuthorization popup later in the app could lead to a rejection from Apple, or these SDKs to not work properly. Or can I let this code like this and call the requestTrackingAuthorization later without any issue?
Thank you
Firebase should always be the last initialization before the return true. Otherwise your code is good.
in our app we are logging (with an external analytics service) every time the user open our app.
However, we have noticed that there are many weird app sessions (almost 15% of total sessions).
Following the device timestamp of the events, the following methods are called:
application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?)
applicationDidBecomeActive(_ application: UIApplication)
viewDidAppear(_ animated: Bool) // App Splash Screen
applicationDidEnterBackground(_ application: UIApplication)
Looking at the timestamp, from didFinishLaunchingWithOptions to applicationDidEnterBackground there is just a very short delay (<1 sec).
Our hypothesis is that the system sometimes wakes up the app without it being actually opened and "seen" by the user. But we can't find any docs about this kind of use case, and we can't reproduce ourself the issue.
Did someone have experienced something similar?
EDIT:
I want to add that these suspicious sessions are often (but not always) linked to an app update.
I'm not sure...
I suppose if app wasn't user terminated nor suspended but was just put out of memory because other apps needed the memory, then almost a launch options can wake the app up if needed. Some examples:
geofence
interaction with push notification's actions. Example if you have userNotificationCenter(_:didReceive:withCompletionHandler:) implemented...
silent notification
background app refresh
Take a look at here and see what launch options are possible for your app. I'm not sure if all of them can actually launch the app or what...
If you want more visibility into this, then make sure for future you log the launchoptionskey that caused the app to get launched...
You need more info - I would extend your logging to dump the launchOptions dictionary in
application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?)
Looking at UIApplication.LaunchOptionsKey, there are a lot of options which may be involved. Note, as the help says: The contents of this dictionary may be empty in situations where the user launched the app directly
if let lop = launchOptions {
let toLog = lop.map{"\($0.0.rawValue) \($0.1)"}.joined(separator:"\n")
// log the options
...}
I did have an idea this might be related to previewing in AppSwitcher but that doesn't seem to trigger didFinishLaunchingWithOptions, unless you actually bring the app to the front. Maybe some split-screen stuff on iPad? It feels like the app is being invoked in a context where it can't get past the launch screen.
I am trying to implement background fetch in my iOS app (it's a simple http call that downloads some data for later processing).
I enabled background fetch in my project capabilities:
Also in AppDelegate I set minimum fetch interval:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalMinimum)
return true
}
And implemented fetch handler:
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult) -> Void) {
do {
try api.downloadInBackground()
} catch {
Debug(self).error(error)
}
completionHandler(.newData)
}
Testing with Debug -> Simulate Background Fetch or custom scheme with enabled background fetch mode work fine and data gets downloaded:
However, when the app is not being debugged background fetch is never invoked. I've read that there's no strict rule when it happens and some time and networking has to be done. However, I've tried leaving device over a weekend (connected to wifi) after I've tried reading some emails browsing, and still nothing happened. What could be wrong?
(At first, I thought it might something to do with a provisioning profile because I did not update it in the apple developer portal, but there's no option to do that, so I suspect that enabling this capability only in the project locally is enough?
We have implemented the deep link activity in our application. It worked in iOS 11. When we send SMS via a web portal. Its received in iPhone. After updated into iOS 12 the link messages are not received for my iPhone devices. Here is my code below:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let branch: Branch = Branch.getInstance()
branch.initSession(launchOptions: launchOptions, automaticallyDisplayDeepLinkController: true, deepLinkHandler: { params, error in
if error == nil {}}
// Respond to URI scheme links
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
Branch.getInstance().handleDeepLink(url);
return true
}
we have added branch_app_domain, branch_key and URL Type in plist also.
Do we need to add anything in my code ??
After updating a device to iOS 11.2+,the app's AASA file is no longer downloaded reliably onto your user’s device after an app install. As a result, clicking on Universal Links will no longer open the app consistently. You can set forced uri redirect mode on your Branch links to open the app with URI schemes. View details of the issue on the Apple Bug report.
For any further questions, please write to integrations#branch.io.
After the recent iOS 9 update, along with updates to the Facebook SDK (4.6.0), I'm finding that my login session is no longer persisting between app launches.
My flow so far has been pretty simple.
Login to Facebook using the FBSDKLoginButton.
On future View's and Launches check the FBSDKAccessToken.currentAccessToken() to be able to then use Facebook in the app.
What I'm finding is after the recent updates my AccessToken is now showing up as nil if I close and start the app again. This is a major issue because previously, I only had to login once, and then my session was being automatically renewed.
If I'm correct, login should only occur once, and after that the app should be able to either store the info it needs to connect to Facebook in the future, or simply remain with a token that refreshes itself.
Does anyone have any ideas what might have changed to cause this after the iOS9 or 4.6.0 Facebook SDK updates? Is there properties that need to be persisted to then refresh the token in the future or is the token supposed to renew automatically? I'm near 100% positive, the intended experience with Facebook SDK is NOT to have to login on every app launch (When you restart the app, close all the way and open again).
Thanks!
Update
As requested in a response, I added an additional key into the TransportSecurity info of my Plist file. Unfortunately, no luck still.
Adding this line on didFinishLaunchingWithOptions worked for me:
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
Final method looks something like this:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
if let accessToken = FBSDKAccessToken.currentAccessToken(){
print(accessToken)
}else{
print("Not logged In.")
}
return true
}
Reference
This happened to me also when upgrading to FBSDK 4.18.0
Downgrading to 4.17.0 solved it for me.
Even it didn't worked for me when I updated my iOS 9 but after try this solution it worked for me.
1) Add data in info.plist as shown image
For iOS 11 / Swift 4 you should add the following code to your AppDelegate:didFinishLaunchingWithOptions
SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
Final code is:
import FacebookCore
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.\
// FACEBOOK CONFIGURATION
SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}