Push

Info
Ocamba provides powerful messaging services to reach your users.

By initializing the SDK you can quickly and easily receive push notifications.

Push is disabled by default. To use Ocamba push, you have to add the following:


```java
    OcambaHoood.getBuilder().push().init();
```

If you want to read fcm token use following:


```java
    OcambaHoood.getInstance().getFcmToken();
```

For notifications to work in expected way you will need to enable permission. You can easily create and customize a “soft-prompt” to ask users to grant your app permission to send push notifications. If the user selects “Allow”, the system’s push permission prompt appears.


  1. Open manifest file and add following:


<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

  1. Now you can choose SDK to handle permission for you:

```java
    OcambaHoood.getInstance().askForPushNotifications(true, new OcambaHoood.PromptForPushNotificationPermissionCallback() {
    		@Override
    		public void notificationsPermission(boolean accepted) {
        
    			}
		});
```

  1. Or you can handle permission and when user accepts permission call this method:

```java
    OcambaHoood.getInstance().notificationsPermissionAllowed();
```

This method will record user action on Ocamba platform.

Info
NOTE: you’ll need to set up an FCM project and configure push for your app (Add Firebase SDK section).
On This Page