gpt4 book ai didi

ios - 将 deviceToken 从 Objective C 复制到 JavaScript

转载 作者:行者123 更新时间:2023-11-29 04:43:40 25 4
gpt4 key购买 nike

我正在尝试将 Urban Airship 使用的 deviceToken 复制到 didRegisterForRemoteNotificationsWithDeviceToken 中的 localStorage 中方法。

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
UALOG(@"APN device token: %@", deviceToken);

[[UAPush shared] registerDeviceToken:deviceToken];

NSString *jsStatement = [NSString stringWithFormat:@"localStorage.setItem('deviceToken', '%@');", deviceToken];
UALOG(@"%@", jsStatement);

[super writeJavascript:jsStatement];
}

writeJavascript 方法定义于 <PhoneGap/PGPlugin.h>我将其导入到我的 AppDelegate.m 中这会导致此错误,

InstallerAppApple[10848:707] -[AppDelegate writeJavascript:]: unrecognized selector sent to instance 0x15e600

我认为我需要做的是将deviceId保存到objective-c的内存中,然后编写一个插件来返回保存的值。

如何将该 deviceId 保存到我可以在插件方法中访问的全局空间?如何在 Objective c 中获取和设置全局值?有没有更好的方法来使用 PhoneGap 访问 deviceId?

谢谢!

最佳答案

读取错误:

'-[AppDelegate application:didFinishLaunchingWithOptions:]: unrecognized selector sent to instance 0x14d190'

您的应用程序的委托(delegate)未实现
-application:didFinishLaunchingWithOptions: 选择器!

我不使用phonegap,所以我不知道phonegap应用程序是什么样的。

关于ios - 将 deviceToken 从 Objective C 复制到 JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9981543/

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