View Single Post
11/02/15, 03:59 PM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,579
It is possible to add your own notifications provider in order to fake a notification.

I have played around with it a bit in the past, and managed to make a notification with accept and decline button.
The gist of it is that you need to subclass ZO_NotificationProvider and overwrite all the necessary methods.
I am not sure if this code still works, but maybe you can use it as a starting point:
Lua Code:
  1. local MyNotificationProvider = ZO_NotificationProvider:Subclass()
  2. function MyNotificationProvider:New(notificationManager)
  3.     local provider = ZO_NotificationProvider.New(self, notificationManager)
  4.     provider.nextId = 1
  5.     return provider
  6. end
  7.  
  8. function MyNotificationProvider:GetNextId()
  9.     local id = self.nextId
  10.     self.nextId = id + 1
  11.     return id
  12. end
  13.  
  14. function MyNotificationProvider:AddNotification(data)
  15.     if(data.id == nil) then
  16.         local list = self.list
  17.         data.id = self:GetNextId()
  18.         list[data.id] = data
  19.     else
  20.         d("Cannot add a notification with an existing id.")
  21.     end
  22. end
  23.  
  24. function MyNotificationProvider:RemoveNotification(id)
  25.     self.list[id] = nil
  26. end
  27.  
  28. function MyNotificationProvider:Accept(data)
  29.     self:RemoveNotification(data.id)
  30. end
  31.  
  32. function MyNotificationProvider:Decline(data)
  33.     self:RemoveNotification(data.id)
  34. end
  35.  
  36. local myProvider = MyNotificationProvider:New(NOTIFICATIONS)
  37. table.insert(NOTIFICATIONS.providers, myProvider)
  38.  
  39. myProvider:AddNotification( {
  40.     "Hello World!"
  41.     })
  Reply With Quote