Skip to content

Twirelab/nestjs-expo-notifications

Repository files navigation

NestJS Expo Notifications Tests

Injectable Expo Notifications client for Nestjs

Install

npm i @twirelab/nestjs-expo-notifications expo-server-sdk

or

yarn add @twirelab/nestjs-expo-notifications expo-server-sdk

Usage

Add below code into app.module.js file.

import { ExpoNotificationsModule } from "@twirelab/nestjs-expo-notifications"

@Module({
  imports: [
    ExpoNotificationsModule.forRoot({
      // optionally providing an access token if you have enabled push security
      accessToken: "...",
    }),
  ],
})
export class AppModule {}

Now you can inject authentication client into your services, for example:

import { Injectable } from "@nestjs/common"
import { InjectExpoNotifications } from "@twirelab/nestjs-expo-notifications"
import { Expo } from "expo-server-sdk"

@Injectable()
export class AppService {
  constructor(@InjectExpoNotifications() private readonly expo: Expo) {}

  async sendNotifications(): Promise<TokenResponse> {
    return await this.expo.sendPushNotificationsAsync([
      {
        to: "ExponentPushToken[**********************]",
        title: "Testing notifications",
        body: "This is a testing notifications",
      },
    ])
  }
}

About

Injectable Expo Notifications client for Nestjs

Resources

License

Stars

Watchers

Forks

Packages

No packages published