[英]Firebase Dynamic Links Short URL not working as expected
I'm experiencing two issues with the Dynamic Links.我在使用动态链接时遇到了两个问题。 I turned-on the app Diagnostics and the Log says no errors.我打开了应用程序诊断,日志显示没有错误。
Specified custom URL scheme is com.*****.** and Info.plist contains such scheme in CFBundleURLTypes key.performDiagnostic completed successfully.指定的自定义 URL 方案为 com.*****.** 并且 Info.plist 在 CFBundleURLTypes key.performDiagnostic 中包含此类方案已成功完成。 No errors found.没有发现错误。
Issue 1:问题 1:
Dynamic Link short URL's are working through the Safari browser in the Simulator (showing a preview screen to open the app instead of opening the app directly. Not working on the real device though. Attaching the screenshot).动态链接短 URL 正在通过模拟器中的 Safari 浏览器工作(显示预览屏幕以打开应用程序而不是直接打开应用程序。虽然在真实设备上不起作用。附上屏幕截图)。 However, it is not working through Email, Skype or WhatsApp etc. The app is woken in all cases by triggering continueUserActivity
with the UserActivity
details.但是,它无法通过 Email、Skype 或 WhatsApp 等工作。在所有情况下,通过使用UserActivity
详细信息触发continueUserActivity
来唤醒应用程序。
The userActivity.webpageURL
returns the Long URL
and userActivity.referrerURL
returns my Short URL
while waking the app though the Safari browser preview screen on the Simulator. userActivity.webpageURL
返回Long URL
, userActivity.referrerURL
返回我的Short URL
,同时通过模拟器上的 Safari 浏览器预览屏幕唤醒应用程序。
The userActivity.webpageURL
returns the Short URL
(instead of the Long URL
) and userActivity.referrerURL
returns https://mail.google.com/mail/mu/mp/789/ (instead of the Short URL
) while waken the app through Email, Skype or WhatsApp etc. userActivity.webpageURL
返回Short URL
(而不是Long URL
)并且userActivity.referrerURL
返回https://mail.google.com/mail/mu/mp/789/ (而不是Short URL
)同时唤醒应用程序Email、Skype 或 WhatsApp 等。
Issue 2:问题 2:
handleUniversalLink
callback is always returns NO
. handleUniversalLink
回调总是返回NO
。 I called stringByRemovingPercentEncoding
to the userActivity.webpageURL
before passing it to the handleUniversalLink
.在将它传递给userActivity.webpageURL
之前,我将stringByRemovingPercentEncoding
调用给handleUniversalLink
。 Still no luck.仍然没有运气。
Long URL Example:长 URL 示例:
baseurl.com/?isi=1505486543&ibi=com%2Eappname%2Eiosappname&link=https%3A%2F%2Fstaging%2Edomain%2Ecom%2F%3Freferral%2Dcode%1234569&si=https%3A%2F%2Fappname%2Dstaging%2Es3%2Dap%2Dsitename%2D1%2Eamazonaws%2Ecom%2FReferralProgram%2F1583824361%5F1638450020%2Ejpg&sd=SHARE%20WITH%20YOUR%20FRIENDS&st=test&apn=com%2Edomain%2Eandroidappname baseurl.com/?isi=1505486543&ibi=com%2Eappname%2Eiosappname&link=https%3A%2F%2Fstaging%2Edomain%2Ecom%2F%3Freferral%2Dcode%1234569&si=https%3A%2F%2Fappname%2Dstaging%2Es3%2Dap%2Dsitename %2D1%2Amazonaws%2Ecom%2FReferralProgram%2F1583824361%5F1638450020%2Ejpg&sd=SHARE%20WITH%20YOUR%20FRIENDS&st=test&apn=com%2Edomain%2Eandroidappname
Short URL Example:简称 URL 示例:
https://domain-deeplink-link.com/123456 https://domain-deeplink-link.com/123456
Long & Short URL Generation Code Long & Short URL 代号
NSURL *link = [[NSURL alloc] initWithString:[kBaseURLForShare stringByAppendingString:[NSString stringWithFormat:@"?referral-code=%@", self.lblReferralID.text]]];
NSString *dynamicLinksDomainURIPrefix = @"deeplink_url.com";
FIRDynamicLinkComponents *linkBuilder = [[FIRDynamicLinkComponents alloc]
initWithLink:link
domain:dynamicLinksDomainURIPrefix];
//iOS params
linkBuilder.iOSParameters = [[FIRDynamicLinkIOSParameters alloc]
initWithBundleID:@"iosbundle_id"];
linkBuilder.iOSParameters.appStoreID = @"store_id";
//Android params
linkBuilder.androidParameters = [[FIRDynamicLinkAndroidParameters alloc]
initWithPackageName:@"android_bundle_id"];
//Social params
linkBuilder.socialMetaTagParameters = [[FIRDynamicLinkSocialMetaTagParameters alloc] init];
if (self.bannerInfo.title.length > 0) {
linkBuilder.socialMetaTagParameters.title = self.bannerInfo.title;
}
if (self.bannerInfo.sharedDescription.length > 0) {
linkBuilder.socialMetaTagParameters.descriptionText = self.bannerInfo.sharedDescription;
}
if (self.bannerInfo.bannerURL.length > 0) {
linkBuilder.socialMetaTagParameters.imageURL = [NSURL URLWithString:[kBaseURLForFiles stringByAppendingString:_bannerInfo.bannerURL]];
}
[FIRDynamicLinkComponents shortenURL:linkBuilder.url
options:nil
completion:^(NSURL * _Nullable shortURL,
NSArray<NSString *> * _Nullable warnings,
NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
[self->_progressHUD hideWithoutAnimation];
self->_progressHUD = nil;
if (error) {
[self showToast:error.localizedDescription];
}
else if (shortURL == nil) {
[self showToast:@"No deeplink URL found!"];
}
else {
[self shareReferralProgramToApps:shortURL.absoluteString Sender:sender];
}
});
}];
AppDelegate Code: AppDelegate代码:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url];
if (dynamicLink) {
if (dynamicLink.url) {
[self processDynamicURL:dynamicLink.url.absoluteString];
} else {
// Dynamic link has empty deep link. This situation will happens if
// Firebase Dynamic Links iOS SDK tried to retrieve pending dynamic link,
// but pending link is not available for this device/App combination.
// At this point you may display default onboarding view.
}
return YES;
}
return NO;
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
restorationHandler:
#if defined(__IPHONE_12_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_12_0)
(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> *_Nullable))restorationHandler {
#else
(nonnull void (^)(NSArray *_Nullable))restorationHandler {
#endif // __IPHONE_12_0
NSURL *activityURL = [NSURL URLWithString:[userActivity.webpageURL.absoluteString stringByRemovingPercentEncoding]];
BOOL handled = [[FIRDynamicLinks dynamicLinks] handleUniversalLink:activityURL
completion:^(FIRDynamicLink * _Nullable dynamicLink,
NSError * _Nullable error) {
[self processDynamicURL:dynamicLink.url.absoluteString];
}];
return handled;
}
Additional Notes:补充笔记:
Any Help on this is highly appreciated.非常感谢对此的任何帮助。 Thank you in advance.先感谢您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.