Suggestion on how to link APN's device token to a registered user (through phonegap or UIWebView)

前端 未结 3 1078
南旧
南旧 2021-02-01 11:52

Similar question here: jQueryMobile, Phonegap and Device Token - iOS

The scenario is, I have this PhoneGap web based application, and the native iOS help me registered t

3条回答
  •  有刺的猬
    2021-02-01 11:56

    The previous answers are really great ways to solve this problem and they do it in a very formal fashion. However, if you want a quick and dirty method of solving the problem, you can simply do this:

    at the bottom of didRegisterForRemoteNotificationsWithDeviceToken add

    NSString* jsString = [NSString stringWithFormat:@"var deviceToken = \"%@\";", deviceToken];
    [self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString];
    

    In your javascript

    deviceId = (typeof deviceToken !== "undefined") ? deviceToken : null;
    

提交回复
热议问题