我终于成功实现了动态链接(手动创建并由 Rest API 缩短),它工作正常并在单击时打开游戏。
问题是,一旦打开,我就无法从中取回任何东西。我从文档中复制了示例代码,添加了一些日志,但什么也没有。
这是我的代码,
// When the app starts, check to make sure that we have
// the required dependencies to use Firebase, and if not,
// add them if possible.
void Start()
{
dependencyStatus = Firebase.FirebaseApp.CheckDependencies();
if (dependencyStatus != Firebase.DependencyStatus.Available)
{
Firebase.FirebaseApp.FixDependenciesAsync().ContinueWith(task => {
dependencyStatus = Firebase.FirebaseApp.CheckDependencies();
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
InitializeFirebase();
} else
{
Debug.LogError("Could not resolve all Firebase dependencies: " + dependencyStatus);
}
});
} else {
InitializeFirebase();
}
}
// Set the listeners for the various Invite received events.
void InitializeFirebase()
{
Firebase.Invites.FirebaseInvites.InviteReceived += OnInviteReceived;
Firebase.Invites.FirebaseInvites.InviteNotReceived += OnInviteNotReceived;
Firebase.Invites.FirebaseInvites.ErrorReceived += OnErrorReceived;
Debug.Log("Invites initialized");
}
void OnInviteReceived(object sender, Firebase.Invites.InviteReceivedEventArgs e)
{
Debug.Log ("OnInviteRecieved");
if (e.InvitationId != "")
{
Debug.Log("Invite received: Invitation ID: " + e.InvitationId);
Firebase.Invites.FirebaseInvites.ConvertInvitationAsync(e.InvitationId).ContinueWith(HandleConversionResult);
}
if (e.DeepLink.ToString () != "")
{
Debug.Log ("Invite received: Deep Link: " + e.DeepLink);
PrepareLevel (e.DeepLink.ToString ());
}
}
void OnInviteNotReceived(object sender, System.EventArgs e)
{
Debug.Log ("OnInviteNotReceived");
Debug.Log("No Invite or Deep Link received on start up");
}
void OnErrorReceived(object sender, Firebase.Invites.InviteErrorReceivedEventArgs e)
{
Debug.Log ("OnErrorReceived");
Debug.LogError("Error occurred received the invite: " + e.ErrorMessage);
}
void HandleConversionResult(Task convertTask)
{
Debug.Log ("HandleConversionResult");
if (convertTask.IsCanceled) {
Debug.Log("Conversion canceled.");
} else if (convertTask.IsFaulted) {
Debug.Log("Conversion encountered an error:");
Debug.Log(convertTask.Exception.ToString());
} else if (convertTask.IsCompleted) {
Debug.Log("Conversion completed successfully!");
}
}
这是我从设备(iPhone6S)获得的日志。
另外,已经提示“Invites initialized”,并且从动态链接打开应用时该对象仍然存在(它从未被破坏)。
哦,我通过 facebook messenger 应用打开了链接。
所有帮助将不胜感激。