0
votes

I'm new in ionic framework, developing one simple app using ionic framework. Implementing push notification, am following below link https://devdactic.com/android-push-notifications/ went up to final step:

$ionicPlatform.ready(function() {
var io = Ionic.io();
var push = new Ionic.Push({
  "onNotification": function(notification) {
    alert('Received push notification!');
  },
  "pluginConfig": {
    "android": {
      "iconColor": "#0000FF"
    }
  }
});
var user = Ionic.User.current();

if (!user.id) {
  user.id = Ionic.User.anonymousId();
}

// Just add some dummy data..
user.set('name', 'Simon');
user.set('bio', 'This is my little bio');
user.save();

var callback = function(data) {
  push.addTokenToUser(user);
  user.save();
};
push.register(callback);

});

After this run the below commend ionic serve -w safari

getting the below error in console ( check last line) Ionic Core: init ionic.io.bundle.min.js:2Ionic Core: searching for cordova.js ionic.io.bundle.min.js:2Ionic Core: attempting to mock plugins app.js:26TypeError: 'undefined' is not a function (evaluating 'Ionic.User.anonymousId()')

if i run "ionic info" getting following lines

Your system information:

Cordova CLI: 6.1.0 (cordova-lib@undefined) Ionic Version: 1.2.4 Ionic CLI Version: 1.7.14 Ionic App Lib Version: 0.7.0 OS: Windows 7 SP1 Node Version: v5.0.0


Dependency warning - for the CLI to run correctly, it is highly suggested to install/upgrade the following:

Please install your Cordova CLI to version >=4.2.0 npm install -g cordova

1

1 Answers

0
votes

The Ionic Platform has now moved to Beta status. Part of this change is the introduction of the Platform API and User authentication. We've deprecated the alpha API for the Users and Push services and will be removing them entirely in the coming months.

Users now require Authentication, so Ionic.User.anonymousId(); is not available.

Have a look at Migrations and user usage.