Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getOneSignalNotificationsCount method added #1090

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -349,6 +349,16 @@ public void onFailure(JSONObject response) {
e.printStackTrace();
}
}

@ReactMethod
public void getOneSignalNotificationsCount(final Callback callback) {
OneSignal.getOneSignalNotificationsCount(new OneSignal.GetNotificationsCountHandler() {
@Override
public void notificationsAvailable(int count) {
callback.invoke(count);
}
});
}

@ReactMethod
public void clearOneSignalNotifications() {
Expand Down
13 changes: 13 additions & 0 deletions index.js
Expand Up @@ -382,6 +382,19 @@ export default class OneSignal {
else
RNOneSignal.postNotification(contents, data, player_id, otherParameters);
}

static getOneSignalNotificationsCount(callback) {
if (!checkIfInitialized()) return;

if (Platform.OS === 'android') {
if (callback === undefined)
callback = function(){};

RNOneSignal.getOneSignalNotificationsCount(callback);
} else {
console.log("This function is not supported on iOS");
}
}

static clearOneSignalNotifications() {
if (!checkIfInitialized()) return;
Expand Down