IONICでアンドロイドのプッシュ通知を開発するにはどうすればよいですか? 実例コードを教えてください。GCMを使用したプッシュ通知とionicの完全な例でのandorid
ここに私のコードです。
ファイル名はapp.js
.config(['$ionicAppProvider', function($ionicAppProvider)
{
$ionicAppProvider.identify({
app_id: 'APP_ID,
api_key: 'PUBLIC_KEY'
});
}])
.controller('PushCtrl', function($scope, $rootScope, $ionicUser, $ionicPush)
{
$rootScope.$on('$cordovaPush:tokenReceived', function(event, data)
{
alert("Successfully registered token " + data.token);
console.log('Ionic Push: Got token ', data.token, data.platform);
$scope.token = data.token;});
$scope.identifyUser = function()
{
var user = $ionicUser.get();
if(!user.user_id)
{
// Set your user_id here, or generate a random one.
user.user_id = $ionicUser.generateGUID();
};
// Metadata
angular.extend(user, {
name: 'Simon',
bio: 'Author of Devdactic'
});
// Identify your user with the Ionic User Service
$ionicUser.identify(user).then(function()
{
$scope.identified = true;
console.log('Identified user'+user.name+'\n ID'+user.user_id);
});
};
//あなたは私が間違っているところ教えてくださいできますプッシュ通知
$scope.pushRegister = function()
{
console.log('Ionic Push: Registering user');
// Register with the Ionic Push service. All parameters are optional.
$ionicPush.register({
canShowAlert: true, //Can pushes show an alert on your screen?
canSetBadge: true, //Can pushes update app icon badges?
canPlaySound: true, //Can notifications play a sound?
canRunActionsOnWake: true, //Can run actions outside the app,
onNotification: function(notification)
{
return true;
}
});
};
});
するためのデバイスを登録しています。私はこのライン
<script src="lib/angular-websocket/angular-websocket.js"></script>
あなたは[この文書](http://docs.ionic.io/docs/push-sending-push)を参照していますか? –
[こちら](https://thinkster.io/ionic-push-notifications-tutorial)も参照してください... –