Hello,
My code: https://gist.github.com/jprangenberg/171bc6bad0834d20d44a
The creation of an ionic user works fine. But the user have no device token. The ‘tokenReceived’ callback function is not called.
Help! Thanks.
Hello,
My code: https://gist.github.com/jprangenberg/171bc6bad0834d20d44a
The creation of an ionic user works fine. But the user have no device token. The ‘tokenReceived’ callback function is not called.
Help! Thanks.
Hey!
The code you posted looks good, as far as registering for push notifications goes, so it’s probably something else preventing you from getting a token. There’s probably some useful errors being logged when you attempt to register and I’d be able to help more specifically if I could see those, but here’s a couple thoughts off the top of my head:
dev_push
mode for testing, which can be enabled by running ionic config set dev_push true
in the root of your project directory. More docs on this here
no valid 'aps entitlement' string
, or something to that effect.ionic set gcm_key <your-sender-id>
Hey fuiste,
thanks for your fast reply.
ionic set gcm_key <your-sender-id>
? Should i do this once?Thank you!
Hey fuiste,
it doesn’t work. I have done all things again.
I doesn’t get an ionic user with device tokens. What is going wrong here?
I have the same problem (native Android device):
Same problem here. GCM key, APP_ID and Secret is set correctly, and user identification works fine.
The console log of REGISTERED OK shows my token, but when I look in ionic users there is no token available.
Hello momsenmeister, hello alex77,
i have solved my issue!
Old code: https://gist.github.com/jprangenberg/171bc6bad0834d20d44a
New code: https://gist.github.com/jprangenberg/5c6822c76b28f0f63d56
It seems also to be important to install following ngCordova plugin: http://ngcordova.com/docs/plugins/pushNotifications/
I hope that fix your problems.
Hello jprangenberg,
I don’t really understand your changes, where do you execute $ionicPush.identify()…?
Hello momsenmeister,
i don’t call identify direct. On line 25, i send data of the user to identify him. Take a look at
the ‘register’ function of ionic push.
https://gist.github.com/jprangenberg/5c6822c76b28f0f63d56#file-pushv2-js-L25
Important: install ngCordova module “pushNotifications”: http://ngcordova.com/docs/plugins/pushNotifications/
Still can’t get it working
All works fine with dev notifications, but on my device I just can’t get a token.
This listener is never called, and the ionic dashboard shows “No Android device tokens for this user”.
$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;
});
Any more ideas?
I’ve tried all this - still the same problem; no device tokens in dashboard. Here’s my code in case it helps:
$scope.login = function(form) {
AuthService.login($scope.user).then(function(response) {
// register device for push
$ionicPush.register({
canShowAlert: false,
canSetBadge: true,
canPlaySound: true,
canRunActionsOnWake: true,
onNotification: function(notification) {
alert(JSON.stringify(notification));
return true;
}
}, {
user_id: response.puserId
});
var user = $ionicUser.get();
// Metadata
_.extend(user, {
username: $scope.user.username
});
$state.go('app.beacons');
}, function(error) {
UIService.showAlert({
title: 'Oops!',
template: error
})
})
}
$scope.logout = function(form) {
$rootScope.currentUser = null
$state.go('login');
}
// Handles incoming device tokens
$rootScope.$on('$cordovaPush:tokenReceived', function(event, data) {
console.log('Ionic Push: Got token ', data.token, data.platform);
$scope.token = data.token;
});
Do you have installed the ngCordova module “pushNotifications”?
Finally solved it by just updating ionic to 1.1.0 and the plugins accordingly.
The code was fine all the time
So, anyone who still has issues - make sure to update all your dependencies first!!!
Can you tell the others, how you update all your dependencies?
Check Plugin IOS
AppDelegate+notification.h
AppDelegate+notification.m
PushPlugin.h
PushPlugin.m
Add a reference for this plugin to the plugins section in config.xml:
<feature name="PushPlugin">
<param name="android-package" value="com.plugin.gcm.PushPlugin" />
<param name="ios-package" value="PushPlugin" />
</feature>
Hello,
Same issue as described. Real device right data and that even worked a month ago. Then without changing any code I see that
$rootScope.$on('$cordovaPush:tokenReceived', function(event, data) {
callback is not called now.
Updated to ionic 1.1.0
Checked push plugin installed.
Updated config.xml with name=“PushPlugin” section.
jprangenberg, don’t see your github pages, can you bring thm\em back?