ios - 将 Parse 推送通知与 Phonegap 集成

标签 ios cordova phonegap-plugins

我正在 phonegap 中开发一个支持解析推送通知的应用程序。我遵循了以下步骤:

  1. 创建 coredova 项目,并使用终端导航到项目文件夹。

  2. 运行解析插件安装命令:

    cordova 插件添加 https://github.com/benjie/phonegap-parse-plugin

  3. 在我的 DeviceReady 方法中,我已经初始化了解析:

    onDeviceReady: function() {
    var PARSE_APP = "MYPARSEAPPID";
    var PARSE_CLIENT = "MYCLIENTID";
    parsePlugin.initialize(PARSE_APP, PARSE_CLIENT, function() {
                           alert('done');
                           }, function(e) {
                           alert('error');
                           });}
    

    当我执行我的代码时,我成功地完成了警报,但是在解析中没有初始化。我错过了一些步骤吗?

我已经使用 XCode 来运行该项目。

最佳答案

您尚未从 git 链接中复制所有代码。 将 parsePlugin.initialize 更改为

parsePlugin.initialize(appId, clientKey, function() {

parsePlugin.subscribe('SampleChannel', function() {

    parsePlugin.getInstallationId(function(id) {

        /**
         * Now you can construct an object and save it to your own services, or Parse, and corrilate users to parse installations
         * 
         var install_data = {
            installation_id: id,
            channels: ['SampleChannel']
         }
         *
         */

    }, function(e) {
        alert('error');
    });

}, function(e) {
    alert('error');
});

}, function(e) {
alert('error');
});

parsePlugin.subscribe 代码为您的设备安装添加 channel 。

关于ios - 将 Parse 推送通知与 Phonegap 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35463023/

相关文章:

ios - Cordova 1.9 到 2.0 升级导致 "#import <Cordova/CDVPlugin.h>"File Not Found 错误

android - 如何使用 phoneGap 安装/卸载 apk android?

ios - 从 UIActionSheet 类中关闭 UIViewController

ios - 为什么将 iOS 应用程序移植到 tvOS 不起作用?

cordova - 使用 cordova CLI 将应用程序部署到 WP8 设备

iphone - 使用 JavaScript 的 PhoneGap 应用程序中类似 Instagram 的过滤器

javascript - Phonegap (Cordova) iOS 推送通知 onNotificationAPN 事件在后台触发

ios - ibeacons 和地理围栏结合 swift

ios - 为什么在这里使用复合语句?

ios - 链接到外部 www 文件夹 - Apache Cordova 工具 (VS 2015)