gpt4 book ai didi

ios - 观看 App 以确定用户是否在 iPhone 上登录?

转载 作者:行者123 更新时间:2023-11-29 10:31:58 27 4
gpt4 key购买 nike

我有一个使用 Parse.com 的现有 iOS 应用程序。您可以使用用户名和密码、Facebook 或 twitter 登录,也可以创建新的登录名。我正在准备更新,它有一个 WatchKit 扩展,可以在新的 Apple Watch 上运行精简版。我想知道如何让 watch 检查 iPhone 上是否存在现有的 PFUser,或者 iPhone 用户是否已注销。您对此有何建议?

我的 AppDelegate 中有 Parse 应用程序的应用程序 ID,并在 AppDelegate 中初始化 PFTwitterUtilsPFFFacebookUtils,但是从 watch 运行时不会调用它们。

最佳答案

前段时间我遇到了同样的问题,我最终决定使用 darwinNotifications 在 iPhone 应用程序和 applewatch 之间发送通知,并在它们之间共享数据我使用了 SharedGroups。所以当用户登录时:1)我在共享组中写用户2) 我从 iOS 应用程序向 Apple Watch 发送 Darwin 通知3) Apple Watch收到darwin通知,读取共享组,查看是否有新用户。

此代码发送 Darwin 通知:

//Write the user on shared groups 
CFNotificationCenterRef notification = CFNotificationCenterGetDarwinNotifyCenter ();
CFStringRef UserLoggedInCFString = (__bridgeCFStringRef)DarwinNotificationUserLoggedIn;
CFNotificationCenterPostNotification(notification, UserLoggedInCFString, NULL, NULL, YES);

applewatch 上的这段代码检测到通知:

CFNotificationCenterRef notificationUserLoggedIn = CFNotificationCenterGetDarwinNotifyCenter (); // 1
CFStringRef userLoggedInCFString = (__bridgeCFStringRef)DarwinNotificationUserLoggedIn;
CFNotificationCenterAddObserver(notificationUserLoggedIn, (__bridge const void *)(self), &userHasLogguedIn, userLoggedInCFString,NULL, CFNotificationSuspensionBehaviorDeliverImmediately);

void userHasLogguedIn(CFNotificationCenterRef center,
void *observer,
CFStringRef name,
const void *object,
CFDictionaryRef userInfo)
{
//Read the user from shared groups.
}

关于ios - 观看 App 以确定用户是否在 iPhone 上登录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29169031/

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