@@ -652,10 +652,8 @@ Sends notifications to your users
652652``` python
653653import onesignal
654654from onesignal.api import default_api
655- from onesignal.model.rate_limit_error import RateLimitError
656- from onesignal.model.generic_error import GenericError
655+ from onesignal.model.language_string_map import LanguageStringMap
657656from onesignal.model.notification import Notification
658- from onesignal.model.create_notification_success_response import CreateNotificationSuccessResponse
659657from pprint import pprint
660658
661659# See configuration.py for a list of all supported configuration parameters.
@@ -667,22 +665,24 @@ configuration = onesignal.Configuration(
667665)
668666
669667
670- # Enter a context with an instance of the API client
671668with onesignal.ApiClient(configuration) as api_client:
672- # Create an instance of the API class
673669 api_instance = default_api.DefaultApi(api_client)
674- notification = Notification(None )
675-
676- # example passing only required values which don't have defaults set
670+ notification = Notification(
671+ app_id = ' YOUR_APP_ID' ,
672+ contents = LanguageStringMap(en = ' Hello from OneSignal!' ),
673+ include_aliases = {' external_id' : [' YOUR_USER_EXTERNAL_ID' ]},
674+ target_channel = ' push' ,
675+ )
677676 try :
678- # Create notification
679677 api_response = api_instance.create_notification(notification)
680- pprint(api_response)
678+ if not api_response.id:
679+ print (' Notification was not created:' , api_response.errors)
680+ else :
681+ pprint(api_response)
681682 except onesignal.ApiException as e:
682- print (" Exception when calling DefaultApi->create_notification: %s \n " % e)
683+ print (' Exception when calling DefaultApi->create_notification: %s \n ' % e)
683684```
684685
685-
686686### Parameters
687687
688688Name | Type | Description | Notes
0 commit comments