Interface PushNotificationsService
- 
- All Known Implementing Classes:
- AndroidPushNotificationsService,- IOSPushNotificationsService
 
 public interface PushNotificationsServiceAdds the ability for the application to receive remote push notifications.Example PushNotificationsService.create().ifPresent(service -> { service.tokenProperty.addListener((observable, oldValue, newValue) -> { if (newValue != null) { String deviceToken = newValue; // This deviceToken can be used to send push notifications to this device by calling // the appropriate server API for the platform. Usually, this token is sent to a server // where the push notifications are created and sent out. } }); service.register(); });Android Configuration To enable push notifications on android, an existing Google Firebase project is required. Copy the google-services.jsonfile into your project'ssrc/android/resourcesfolder.The following permissions,servicesandreceiverneed to be added to the android manifest configuration file to make push notifications work on android. The main activity also requires the attributeandroid:launchModewith valuesingleTop.
 Note: All these modifications are handled automatically by the Gluon Client plugin during the package goal.<manifest ...> ... <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> ... <application ...> <activity android:name="com.gluonhq.helloandroid.MainActivity" android:configChanges="orientation|keyboardHidden" android:launchMode="singleTop"> ... </activity> ... <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver> <service android:name="com.gluonhq.helloandroid.PushFcmMessagingService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> <service android:name="com.gluonhq.helloandroid.PushInstanceIdService"> <intent-filter> <action android:name="com.google.firebase.INSTANCE_ID_EVENT" /> </intent-filter> </service> <service android:name="com.google.firebase.components.ComponentDiscoveryService"> <meta-data android:name="com.google.firebase.components:com.google.firebase.iid.Registrar" android:value="com.google.firebase.components.ComponentRegistrar"/> </service> <service android:name="com.gluonhq.helloandroid.PushNotificationJobService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true" /> <activity android:name="com.gluonhq.helloandroid.PushNotificationActivity" android:parentActivityName="com.gluonhq.helloandroid.MainActivity"> <meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.gluonhq.helloandroid.MainActivity"/> </activity> </application> </manifest>iOS Configuration You need to use a Provisioning Profile that defines the aps-environmentproperty in theEntitlementssection to eitherdevelopmentorproduction.- Since:
- 3.2.0
 
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description static java.util.Optional<PushNotificationsService>create()Returns an instance ofPushNotificationsService.voidregister()Register the app for receiving push notifications.voidregister(java.lang.String authorizedEntity)Deprecated.javafx.beans.property.ReadOnlyStringPropertytokenProperty()The unique registration token that can be passed to the server, so the app can receive push notifications
 
- 
- 
- 
Method Detail- 
createstatic java.util.Optional<PushNotificationsService> create() Returns an instance ofPushNotificationsService.- Returns:
- An instance of PushNotificationsService.
 
 - 
tokenPropertyjavafx.beans.property.ReadOnlyStringProperty tokenProperty() The unique registration token that can be passed to the server, so the app can receive push notifications- Returns:
- a ReadOnlyStringProperty with a unique token
 
 - 
registervoid register() Register the app for receiving push notifications. On iOS this will trigger a confirmation dialog that must be accepted by the user.- Since:
- 4.0.10
 
 - 
register@Deprecated void register(java.lang.String authorizedEntity) Deprecated.Register the app for receiving push notifications. On iOS this will trigger a confirmation dialog that must be accepted by the user. For Android, you need to pass in the authorizedEntity value that matches the Sender ID of your Google Cloud Messaging or Firebase Cloud Messaging application.- Parameters:
- authorizedEntity- a string that matches the Sender ID of a GCM or FCM application
 
 
- 
 
-