패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.1.2

pusher_beams

Pusher Beams 공식 Flutter 플러그인. Pusher Beams를 사용하여 Flutter 애플리케이션에서 알림을 쉽게 받으세요.

AndroidiOSWeb
30일 다운로드
1.2천
좋아요
40
Pub 점수
140

패키지 설치

flutter pub add pusher_beams

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Pusher Beams는 Flutter 애플리케이션에 푸시 알림을 통합하기 위한 공식 플러터 플러그인입니다. 개발자들은 안드로이드, iOS, 웹 플랫폼의 사용자에게 타겟팅되고 개인화된 알림을 보낼 수 있습니다. 이 플러그인은 Pusher의 확장 가능한 인프라를 통해 토큰 등록, 구독 관리 및 메시지 전달을 처리하여 실시간 알림 수신 과정을 단순화합니다. 최소한의 설정으로 개발자는 시의적절하고 관련성 있는 알림을 통해 사용자 참여도를 높일 수 있습니다. 이 플러그인은 Pusher에서 유지보수되며, 그들의 Beams 서비스와 원활하게 통합됩니다.

사용 사례

  • 타겟팅된 푸시 알림 보내기
  • 실시간 알림을 통한 사용자 참여
  • 크로스 플랫폼 알림 전달
  • 사용자 관심사에 기반한 개인화된 메시지
  • 모바일 및 웹 앱에서의 실시간 업데이트

주요 기능

  • 공식 Pusher 플러그인
  • Android, iOS 및 웹을 지원합니다
  • 토큰 관리 및 장치 등록
  • 구독 기반 알림 타겟팅
  • 안전하고 확장 가능한 백엔드 통합

적합한 대상

  • 실시간 알림이 필요한 앱
  • Pusher Beams 서비스를 사용하는 개발자
  • 크로스플랫폼 모바일 및 웹 앱
  • 사용자 중심의 알림 시스템
  • 동적 콘텐츠 업데이트를 지원하는 애플리케이션

고려 사항

  • Pusher Beams 계정 설정이 필요합니다
  • 올바른 Firebase 또는 APNs 구성이 필요합니다
  • Pusher의 알림 인프라스트럭처에 한정
  • 인터넷 연결에 따라 다름
  • 사용자 지정 페이로드를 위해 추가적인 백엔드 로직이 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Pusher Beams for Flutter

Pub Version GitHub likes popularity pub points

Official Flutter Plugin for Pusher Beams using Pigeon for platform plugin interface and Federated Plugin Architecture.

Table of Contents

Architecture

This plugin was developed based on the Federated Plugin Architecture, following packages are included in the plugin:

Flutter Support

This is the comparison table of functions implemented within this plugin according to the native libraries. (Android, iOS, Web)

iOS Android Web
addDeviceInterest ✅ ✅ ✅
clearAllState ✅ ✅ ✅
clearDeviceInterests ✅ ✅ ✅
getDeviceInterests ✅ ✅ ✅
onInterestChanges ✅ ✅ ⬜️
onMessageReceivedInTheForeground ✅ ✅ ⬜️
getInitialMessage ✅ ✅ ⬜️
removeDeviceInterest ✅ ✅ ✅
setDeviceInterests ✅ ✅ ✅
setUserId ✅ ✅ ⬜️
start ✅ ✅ ✅
stop ✅ ✅ ✅

Platform Support

This plugin supports Web, Android and iOS platforms.

Web Support
  • Chrome (mobile & desktop)
  • Safari (mobile & desktop)
  • Edge (mobile & desktop)
  • Firefox (mobile & desktop)

See Web FAQ

Mobile Support
  • iOS 10 and above
  • Android 4.4 and above (>= SDK Version 19)

Example

A fully example using this plugin can be found in this repository, implementing a basic use of most of the functionality included in this plugin.

See Example

Prerequisites

In order to work with this Flutter plugin you must have a Pusher Beams Account and already got an instanceId within your dashboard, you can Sign Up here.

Android Additional
  • Firebase Account and a google-services.json (follow this guide). Do not initialize anything, this plugin just requires a google-services.json within your android/app folder.
  • Enable Multidex (If your minSdkVersion is lower than 21)
  • For Android 12 support,compileSdkVersion must be set to 31 (and if you use kotlin, use the 1.5.30 version)
iOS Additional

Installation

To install this plugin within you Flutter application, you need to add the package into your pubspec.yaml.

    dependencies:
      pusher_beams: ^1.0.1

or with flutter pub

flutter pub add pusher_beams

There are some additional steps for some platforms.

Android
  • Add this line inside your project-level build.gradle which is located at your android folder

    buildscript {
        // Your config...
        
        repositories {
            // Your repositories...
        }
    
        dependencies {
            // Your dependencies...
    
            // Add this line
            classpath 'com.google.gms:google-services:4.2.0'
        }
    }
    
  • Now, on your app-level build.gradle you must include com.google.gms.google-services ( google-services.json must be already included within your app as it's a prerequisite). Just add this line at the end of your app-level build.gradle.

    apply plugin: 'com.google.gms.google-services'
    
Web
  • Create a file called service-worker.js inside your web folder.
  • That file must include the following line:
    importScripts("https://js.pusher.com/beams/service-worker.js");
    
  • Now you must add this <script> tag inside and at the beginning of your <body> tag within the web/index.html file:
    <script src="https://js.pusher.com/beams/1.0/push-notifications-cdn.js"></script>
    

Initialization

If you already have done the prerequisites, now you can initialize Pusher Beams using the start method as soon as possible (Preferable inside the main function).

void main() async {
  // Some initial code
  
  await PusherBeams.instance.start('YOUR INSTANCE ID');
  
  runApp(MyApp());
}

Ensure the bindings are initialized, you can do this by adding the following line inside your main function before you start this plugin.

void main() async {
  // Some initial code

  WidgetsFlutterBinding.ensureInitialized(); // Add this line
  await PusherBeams.instance.start('YOUR INSTANCE ID');

  runApp(MyApp());
}

Overall, that's all! ✨ Now you can use the methods described in the API Reference.

API Reference

If you want to see the API reference in-depth, you may want to see the Official API Reference from pub.dev.

Contributing

In order to contribute you must first read how to develop flutter plugins, this is the basic knowledge to start.

This repository is following git flow branching model, so in order to contribute, once you fork this project, you must create a fix/ or feature/ branch, which will be pull requested from you once it's ready.

Commits follows the conventional commits standard, which scopes are the follow:

So, in order to commit something you must use a commit message like below:

feat(android): i did something to android code :0
Developing Environment
  • Flutter >= 2.x.x (running flutter doctor will check if everything is good to start)
  • To contribute on packages/pusher_beams_ios you must be in MacOS and Xcode must be installed
Running The Tests

There's two major tests, our app-facing package test which is run as Integration Test and our platform-interface package test run as Unit Test

Integration Tests

For integration tests, we use the example app provided in packages/pusher_beams/example. In order to run the integration tests you must complete the prerequisites in the example app which is...

If you already double-check the list above, then you must replace the constant instanceId located on packages/pusher_beams/example/integration_test/pusher_beams_test.dart with a real one from Pusher Beams.

// Code...

const instanceId = 'your-instance-id'; // Replace this with a real instanceId

// More Code...

So that's all! you can now run the integration test with the following command on the example app path (packages/pusher_beams/example):

flutter test integration_test

And for web (Do not forget to read this):

flutter drive \
  --driver=test_driver/integration_test.dart \
  --target=integration_test/pusher_beams_test.dart \
  -d web-server
Unit Tests

In order to run unit tests for packages/pusher_beams_platform_interface you must be in the directory and run the following:

flutter test
Pigeons

As this plugin platform interface is generated by Pigeon and if you modified the file messages.dart from packages/pusher_beams_platform_interface package, in order to generate a new MethodChannel interface you must run the following command on path packages/pusher_beams_platform_interface:

make

After this command you must go to packages/pusher_beams_platform_interface/lib/method_channel_pusher_beams.dart and extends the class PusherBeamsApi with PusherBeamsPlatform like below:

class PusherBeamsApi extends PusherBeamsPlatform {
  // Pigeon Generated Class Code
}

This will require you to change the methods onInterestChanges and setUserId parameter arg_callbackId to type dynamic in order to accomplish PusherBeamsPlatform definition like below:

  // Class code...
  Future<void> onInterestChanges(dynamic arg_callbackId) async {
    // onInterestChanges generated function code...
  }

  Future<void> setUserId(String arg_userId, BeamsAuthProvider arg_provider, dynamic arg_callbackId) async {
    // setUserId generated function code...
  }
  // More class code...

License

Copyright (c) 2015 Pusher Ltd. See LICENSE for details.

카테고리

의존성

의존성 목록 5 개

  • pusher_beams_android^1.1.2
  • pusher_beams_ios^1.1.1
  • pusher_beams_platform_interface^1.1.1
  • pusher_beams_web^1.1.1
  • uuid^3.0.5

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.