github.com/status-im/status-go@v1.1.0/services/local-notifications/api.go (about)

     1  package localnotifications
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/ethereum/go-ethereum/log"
     7  )
     8  
     9  func NewAPI(s *Service) *API {
    10  	return &API{s}
    11  }
    12  
    13  type API struct {
    14  	s *Service
    15  }
    16  
    17  func (api *API) NotificationPreferences(ctx context.Context) ([]NotificationPreference, error) {
    18  	return api.s.db.GetPreferences()
    19  }
    20  
    21  func (api *API) SwitchWalletNotifications(ctx context.Context, preference bool) error {
    22  	log.Debug("Switch Transaction Notification")
    23  	err := api.s.db.ChangeWalletPreference(preference)
    24  	if err != nil {
    25  		return err
    26  	}
    27  
    28  	api.s.WatchingEnabled = preference
    29  
    30  	return nil
    31  }