vri*_*aam 5 cordova parse-platform ionic-framework
我是这个Cordova /离子项目,我正在使用Parse作为后端.我希望用户能够向其他用户发送消息.这样做时,推送通知应出现在接收者的设备上.
这应该适用于Android和iOS.
只使用Ionic和Parse会有可能吗?
我正在做一个类似的项目。
以下是获得基本想法的一些步骤
A。注册到Parse.com
b. 要使用 Ionic 构建项目,您需要一个 JS 插件来访问 Parse 组件。使用此GitHub 插件
C。将以下代码复制粘贴ionicPlatformReady()到app.js
// You'll get the appId and Clinet Key from Parse.com
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');
});
Run Code Online (Sandbox Code Playgroud)
d. 从 Parse 帐户仪表板中,发送用于测试的推送通知,您应该能够看到它。
笔记
您很可能会收到错误消息Reference to parsePlugin not defined.,这意味着 Cordova 插件在执行时未加载。
我希望它有帮助。一切顺利。
谢谢,
| 归档时间: |
|
| 查看次数: |
4442 次 |
| 最近记录: |