Within my app.js file, I have the following method:
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
gvi.Notifications.registerForPush(MessagesService.onNotificationResponse);
});
})
Additionally, I have a factory defined as:
.factory('MessagesService', function($scope, $q) {
var messages = [];
return {
onNotificationResponse: function(sender, message, msgId, msgType, msgUrl) {
console.log("myApp.onNotificationResponse:" + message + " msgUrl:" + msgUrl);
$scope.messages.push({
sender: sender,
message: message,
msgId: msgId,
msgType: msgType,
msgUrl: msgUrl
});
MessagesService.save($scope.messages);
},
}
})
Upon opening the app, I am encountering the following error:
Uncaught ReferenceError: MessagesService is not defined
How can I successfully utilize the MessagesService factory within the ionicPlatform.ready function?
UPDATE:
The error regarding MessagesService has been resolved. Now, how can I incorporate the use of $scope within the factory?