Question:
Can I schedule a local notification using the Pushwoosh SDK/plugin?
Answer:
Yes, it is possible to create and schedule a local notification using the following methods:
Pushwoosh SDK for the native framework:
Android:
LocalNotification notification = new LocalNotification.Builder().setMessage(“Local notification content”)
.setDelay(seconds)
.build();
LocalNotificationRequest request = Pushwoosh.getInstance().scheduleLocalNotification(notification);
“Local notification content” - type your content here
Please do not forget to add RECEIVE_BOOT_COMPLETED permission to your AndroidManifest.xml as per our guide:
iOS:
Local notifications are created using native methods as per Apple documentation:
Unity:
Pushwoosh.Instance.ScheduleLocalNotification ("Hello, Android!", 5, parameters);
Pushwoosh.Instance.SetNotificationChannelDelegate(new MyNotificationChannelDelegate());
Xamarin:
iOS: Local notifications are created at a native level as per Apple documentation:
Android: Use the scheduleLocalNotification method at a native level.
Titanium:
var notificationId = pushwoosh.scheduleLocalNotification(“Your pumpkins are ready!“, 30);
30 - delay for the local notification in seconds
Adobe AIR:
public function scheduleLocalNotification( seconds: int, alertJson: String ):int
pushwoosh.scheduleLocalNotification(30, “{\”alertBody\”: \”Time to collect coins!\”, \”alertAction\”:\”Collect!\”, \”soundName\”:\”sound.caf\”, \”badge\”: 5, \”custom\”: {\”a\”:\”json\”}}”);
React Native:
In Pushwoosh SDK there is no separate method to create a local notification at React Native level itself, however, it is still possible to create it at a native level using the methods above.
Cordova/PGB:
PushNotification.prototype.createLocalNotification = function( config, success, fail )
config.msg – notification message
config.seconds – notification delay in seconds
config.userData– additional data to pass in notification
success – success callback
fail – error callback
Example:
pushwoosh.createLocalNotification({msg:"Your pumpkins are ready!", seconds:30, userData:{}})
Comments
0 comments
Please sign in to leave a comment.