use onesignal\client\api\DefaultApi;use onesignal\client\Configuration;use GuzzleHttp;$config = Configuration::getDefaultConfiguration() ->setRestApiKeyToken('YOUR_REST_API_KEY') ->setOrganizationApiKeyToken('YOUR_ORGANIZATION_API_KEY');$client = new DefaultApi( new GuzzleHttp\Client(), $config);
using OneSignalApi.Api;using OneSignalApi.Client;var config = new Configuration();config.BasePath = "https://api.onesignal.com";config.AccessToken = "YOUR_REST_API_KEY";var client = new DefaultApi(config);
use onesignal::apis::configuration::Configuration;fn create_configuration() -> Configuration { let mut config = Configuration::new(); config.rest_api_key_token = Some("YOUR_REST_API_KEY".to_string()); config.organization_api_key_token = Some("YOUR_ORGANIZATION_API_KEY".to_string()); config}
use onesignal\client\model\Notification;use onesignal\client\model\StringMap;$content = new StringMap();$content->setEn('Hello from OneSignal!');$headings = new StringMap();$headings->setEn('Push Notification');$notification = new Notification();$notification->setAppId('YOUR_APP_ID');$notification->setContents($content);$notification->setHeadings($headings);$notification->setIncludedSegments(['Subscribed Users']);$response = $client->createNotification($notification);echo 'Notification ID: ' . $response->getId();
const notification = new OneSignal.Notification();notification.app_id = 'YOUR_APP_ID';notification.email_subject = 'Important Update';notification.email_body = '<h1>Hello!</h1><p>This is an HTML email.</p>';notification.included_segments = ['Subscribed Users'];notification.channel_for_external_user_ids = 'email';const response = await client.createNotification(notification);
notification = onesignal.Notification( app_id='YOUR_APP_ID', email_subject='Important Update', email_body='<h1>Hello!</h1><p>This is an HTML email.</p>', included_segments=['Subscribed Users'], channel_for_external_user_ids='email',)response = client.create_notification(notification)
Notification notification = new Notification();notification.setAppId("YOUR_APP_ID");notification.setEmailSubject("Important Update");notification.setEmailBody("<h1>Hello!</h1><p>This is an HTML email.</p>");notification.setIncludedSegments(Arrays.asList("Subscribed Users"));notification.setChannelForExternalUserIds("email");var response = client.createNotification(notification);
notification := *onesignal.NewNotification("YOUR_APP_ID")notification.SetEmailSubject("Important Update")notification.SetEmailBody("<h1>Hello!</h1><p>This is an HTML email.</p>")notification.SetIncludedSegments([]string{"Subscribed Users"})notification.SetChannelForExternalUserIds("email")response, _, err := apiClient.DefaultApi .CreateNotification(orgAuth) .Notification(notification) .Execute()
$notification = new Notification();$notification->setAppId('YOUR_APP_ID');$notification->setEmailSubject('Important Update');$notification->setEmailBody('<h1>Hello!</h1><p>This is an HTML email.</p>');$notification->setIncludedSegments(['Subscribed Users']);$notification->setChannelForExternalUserIds('email');$response = $client->createNotification($notification);
notification = OneSignal::Notification.new({ app_id: 'YOUR_APP_ID', email_subject: 'Important Update', email_body: '<h1>Hello!</h1><p>This is an HTML email.</p>', included_segments: ['Subscribed Users'], channel_for_external_user_ids: 'email'})response = client.create_notification(notification)
var notification = new Notification(appId: "YOUR_APP_ID"){ EmailSubject = "Important Update", EmailBody = "<h1>Hello!</h1><p>This is an HTML email.</p>", IncludedSegments = new List<string> { "Subscribed Users" }, ChannelForExternalUserIds = "email"};var response = client.CreateNotification(notification);
let mut notification = Notification::new("YOUR_APP_ID".to_string());notification.email_subject = Some("Important Update".to_string());notification.email_body = Some("<h1>Hello!</h1><p>This is an HTML email.</p>".to_string());notification.included_segments = Some(vec!["Subscribed Users".to_string()]);notification.channel_for_external_user_ids = Some("email".to_string());let response = default_api::create_notification(&config, notification).await;