离子启动 pushCall 离子登录 离子上传
//打开谷歌控制台 1-创建项目 2-使用谷歌 API 1-移动 API 2-选择谷歌云消息并启用它 3-转到凭据并创建 API 密钥
//之后添加以下插件
ionic add ionic-platform-web-client ionic plugin add phonegap-plugin-push --variable SENDER_ID="991785317333" (添加gcm号码时不要删除引号)
//添加平台
离子平台添加 android 离子 io init 离子配置集 dev_push true
//open ionic io go to setting 1-create api key
2-go to certificate and create security profile name edit id click on android and add GCM key and save it.
//add this code to app.js
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
var push = new Ionic.Push({
"debug": true
});
push.register(function(token) {
console.log("My Device token:",token.token);
push.saveToken(token); // persist the token in the Ionic Platform
});
});
})
//使用 ionic io open launch postman 测试您的配置是否正确 //然后执行以下操作:
1-create collection give it a valid name
2-in body click on text and select Application/json
it will add header automatically
3-add another header
key as Authorization
value as bearer followed by your api token from ionic io
4-select "raw " as the format of our json
2-in body section of your collection write
following code
{
"tokens": ["DEV_DEVICE_TOKEN"],
"profile": "PROFILE_NAME",
"notification":
{
"message": "This is my demo push!"
}
}
//现在它将在浏览器上提示消息
离子配置集 gcm_key
离子配置集 dev_push false 离子构建 android
在手机中安装您的应用程序并从邮递员发送通知
(Mahesh Sampat Nighut) 新孟买