gpt4 book ai didi

ios - Facebook App 邀请通知在 ios 中不起作用

转载 作者:可可西里 更新时间:2023-11-01 03:06:08 24 4
gpt4 key购买 nike

我在演示应用程序中实现了 Facebook 应用程序邀请。它工作正常,但没有收到通知。

I have added all detail in my question, now can anyone tell me what is the issue in my code and what should I do to resolve this. I have created test users for testing this app.

此代码运行良好,它启动一个对话框,显示好友列表,还显示应用邀请已发送,但当我在好友帐户中查看时,它没有显示任何通知。

My Info.plist File

我想我在 info.plsit 下的 URL Type (URL 计划)。我已经写了 Action ,这是方法的名称,但我没有 知道我应该在这个专栏中写什么。

enter image description here

Appdelegate.m

- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
BFURL *parsedUrl = [BFURL URLWithInboundURL:url sourceApplication:sourceApplication];
if ([parsedUrl appLinkData])
{
NSURL *targetUrl = [parsedUrl targetURL];
[[[UIAlertView alloc] initWithTitle:@"Received link:"
message:[targetUrl absoluteString]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] show];
}
return YES; }

ViewController.h

Getting result null when appInviteDialog:(FBSDKAppInviteDialog
*)appInviteDialog didCompleteWithResults:(NSDictionary *)results
called

- (IBAction)action:(UIButton *)sender
{

FBSDKAppInviteContent *content =[[FBSDKAppInviteContent alloc] init];
content.appLinkURL = [NSURL URLWithString:@"https://fb.me/*****************"];

[FBSDKAppInviteDialog showFromViewController:self withContent:content delegate:self];
}

- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didCompleteWithResults:(NSDictionary *)results
{
NSLog(@" result %@",results);
}
- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didFailWithError:(NSError *)error
{
NSLog(@"error = %@", error);
NSString *message = error.userInfo[FBSDKErrorLocalizedDescriptionKey] ?:
@"There was a problem sending the invite, please try again later.";
NSString *title = error.userInfo[FBSDKErrorLocalizedTitleKey] ?: @"Oops!";

[[[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];

}

最佳答案

尝试将其放入您的 AppDelegate.m :

在顶部导入:

#import <FBSDKCoreKit/FBSDKCoreKit.h>

并将其用于应用程序:openurl: sourceapplication: annotation

- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
{
if (!url) {
return NO;
}

[[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];

return YES;
}

这使用 Facebook SDK 来处理 openurls 而不是自定义处理程序。

这将触发您定义的委托(delegate)方法,然后您可以继续提醒用户或做任何您想做的事情。

也在你的info.plist URLSchemes值需要与您在 Facebook 输入“带有自定义方案的 URL”中的值相同。例如,如果您有 myapp://在 Facebook 对话框中的“带有自定义方案的 URL”中,然后是您的 URLScheme将是 myapp (你目前有 action )

所做的只是让 Safari 知道如果您调用 myapp://在 URL 栏中然后它应该打开你的应用程序。除非您将参数传递给应用程序,否则您在 myapp:// 之后不需要任何内容​​。在 Facebook 屏幕上。

确保在您的开发者设置 (https://developers.facebook.com/apps/ {app-id}/settings/) 中添加了 iOS 平台,并设置了捆绑 ID 和 iPhone 商店 ID 以及iPad 商店 ID。

Screenshot from my app on Facebook developer page

您可以为 iPhone 和 iPad 应用程序 ID 使用任何应用程序 ID(来自 itunes connect,实际上称为“Apple id”)(只需确保它是来自应用程序商店的有效应用程序 ID,名称不必匹配) 并为您的应用使用您的包 ID。 iPhone 和 iPad 的 ID 可以相同。这是至关重要的,因为如果没有这个,Facebook 不会向用户发送通知,因为如果用户没有下载应用程序,它不知道将用户发送到哪里。将其放入并发送另一个通知,它应该可以工作。

使用 Facebook 的“快速入门”创建应用邀请链接时,请确保您在 iOS 框中正确设置了参数。这是设置应该是什么样子的示例。这是看起来像 https://fb.me/634411166661512 的链接

Example setup of fb app link

无论您在 info.plist 中有什么,“带有自定义方案的 URL”都必须相同- 如果您有 myapp,请使用上面的答案在你的info.plistURLSchemes 下您可以将“myapp://”放入 Facebook“带有自定义方案的 URL”中。应用名称可以是任何名称,仅供显示。虽然它说“App Store Id”是可选的,但它是必需的。确保在这里使用与上面设置“iPad Store Id”和“iPhone Store Id”时相同的一个。如果用户没有您的应用程序,这会告诉 Apple 将用户推送到 iTunes 商店。

关于ios - Facebook App 邀请通知在 ios 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33802803/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com