mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-11 22:55:59 +05:45
Open source FIAM headless SDK (#2312)
This commit is contained in:
1 parent
a43709f18e
commit
3905bd250a
137 files changed
+15462
No files matched your search
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "FIRIAMClearcutUploader.h"
|
||||
#import "FIRIAMRuntimeManager.h"
|
||||
#import "FIRInAppMessaging+Bootstrap.h"
|
||||
#import "NSString+FIRInterlaceStrings.h"
|
||||
|
||||
#import <FirebaseCore/FirebaseCore.h>
|
||||
#import <FirebaseDynamicLinks/FirebaseDynamicLinks.h>
|
||||
|
||||
@interface FIRInAppMessaging (Testing)
|
||||
+ (void)disableAutoBootstrapWithFIRApp;
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
NSLog(@"application started");
|
||||
|
||||
[FIRInAppMessaging disableAutoBootstrapWithFIRApp];
|
||||
[FIROptions defaultOptions].deepLinkURLScheme = @"fiam-testing";
|
||||
[FIRApp configure];
|
||||
|
||||
FIRIAMSDKSettings *sdkSetting = [[FIRIAMSDKSettings alloc] init];
|
||||
|
||||
sdkSetting.apiServerHost = @"firebaseinappmessaging.googleapis.com";
|
||||
|
||||
NSString *serverHostNameFirstComponent = @"pa.ogepscm";
|
||||
NSString *serverHostNameSecondComponent = @"lygolai.o";
|
||||
|
||||
sdkSetting.clearcutServerHost = [NSString fir_interlaceString:serverHostNameFirstComponent
|
||||
withString:serverHostNameSecondComponent];
|
||||
sdkSetting.apiHttpProtocol = @"https";
|
||||
sdkSetting.fetchMinIntervalInMinutes = 0.1; // ok to refetch every 6 seconds
|
||||
sdkSetting.loggerMaxCountBeforeReduce = 800;
|
||||
sdkSetting.loggerSizeAfterReduce = 600;
|
||||
sdkSetting.appFGRenderMinIntervalInMinutes = 0.1;
|
||||
sdkSetting.loggerInVerboseMode = YES;
|
||||
sdkSetting.conversionTrackingExpiresInSeconds = 180;
|
||||
sdkSetting.firebaseAutoDataCollectionEnabled = NO;
|
||||
|
||||
sdkSetting.clearcutStrategy =
|
||||
[[FIRIAMClearcutStrategy alloc] initWithMinWaitTimeInMills:5 * 1000 // 5 seconds
|
||||
maxWaitTimeInMills:30 * 1000 // 30 seconds
|
||||
failureBackoffTimeInMills:60 * 1000 // 60 seconds
|
||||
batchSendSize:50];
|
||||
|
||||
[FIRInAppMessaging bootstrapIAMWithSettings:sdkSetting];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
continueUserActivity:(NSUserActivity *)userActivity
|
||||
restorationHandler:(void (^)(NSArray *))restorationHandler {
|
||||
NSLog(@"handle page url %@", userActivity.webpageURL);
|
||||
BOOL handled = [[FIRDynamicLinks dynamicLinks]
|
||||
handleUniversalLink:userActivity.webpageURL
|
||||
completion:^(FIRDynamicLink *_Nullable dynamicLink, NSError *_Nullable error) {
|
||||
if (dynamicLink) {
|
||||
NSLog(@"dynamic link recogized with url as %@", dynamicLink.url.absoluteString);
|
||||
[self showDeepLink:dynamicLink.url.absoluteString forUrlType:@"universal link"];
|
||||
} else {
|
||||
NSLog(@"error happened %@", error);
|
||||
}
|
||||
}];
|
||||
return handled;
|
||||
}
|
||||
|
||||
- (void)showDeepLink:(NSString *)url forUrlType:(NSString *)urlType {
|
||||
NSString *message = [NSString stringWithFormat:@"App wants to open a %@ : %@", urlType, url];
|
||||
UIAlertController *alert =
|
||||
[UIAlertController alertControllerWithTitle:@"Deep link recognized"
|
||||
message:message
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"OK"
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction *action){
|
||||
}];
|
||||
|
||||
[alert addAction:defaultAction];
|
||||
[UIApplication.sharedApplication.keyWindow.rootViewController presentViewController:alert
|
||||
animated:YES
|
||||
completion:nil];
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)app
|
||||
openURL:(NSURL *)url
|
||||
options:(NSDictionary<NSString *, id> *)options {
|
||||
return [self application:app openURL:url sourceApplication:@"source app" annotation:@{}];
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
openURL:(NSURL *)url
|
||||
sourceApplication:(NSString *)sourceApplication
|
||||
annotation:(id)annotation {
|
||||
NSLog(@"handle link with custom scheme: %@", url.absoluteString);
|
||||
[self showDeepLink:url.absoluteString forUrlType:@"custom scheme url"];
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
Reference in new issue
Block a user