subscribe static method

Future<void> subscribe(
  1. String topic, {
  2. Function? callback,
})

Subscribe to a topic. topic is the name of that topic. The naming rules must follow FCM topic naming standards. callback is an optional function that will be called with result of subscription.

Implementation

static Future<void> subscribe(String topic, {Function? callback}) async {
  if(!Platform.isAndroid) return;
  try {
    if (await (_channel.invokeMethod("Pushe.subscribe", {"topic": topic}))) {
      callback?.call();
    }
  } catch (ignored) {
    return;
  }
  return;
}