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

패키지 상세v1.1.0

deeplink_rpc

Dart로 작성된 딥링크를 통한 RPC 통신 라이브러리입니다. 이는 Flutter 모바일 애플리케이션(iOS / Android) 전용입니다.

AndroidiOSmacOSWindowsLinux
30일 다운로드
142
좋아요
4
Pub 점수
130

패키지 설치

flutter pub add deeplink_rpc

패키지 개요

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

Dart 기반 라이브러리로, iOS 및 안드로이드용 Flutter 애플리케이션에서 딥 링크를 통해 RPC(원격 절차 호출) 통신을 가능하게 합니다. 딥 링크 URL을 활용하여 앱 간 또는 단일 앱의 구성 요소 간에 메서드를 호출하고 데이터를 교환함으로써 보안성 있고 크로스 플랫폼의 앱 간 통신을 지원합니다. 모바일 환경과의 원활한 통합을 위해 설계되었으며, 구조화된 메시지 전달을 지원하며, 전통적인 네트워크 호출에 의존하지 않고 앱 간 상호작용이 필요한 시나리오에 적합합니다. 이 라이브러리는 오픈소스이며 Archethic Foundation에서 유지 관리됩니다.

사용 사례

  • 앱 간 통신
  • Flutter 앱 내 모듈 간 메시지 전달
  • 안전한 원격 메서드 호출
  • 딥 링크를 통한 외부 작업 처리
  • 데이터 전송과 함께 간편한 탐색

주요 기능

  • 딥 링크 기반의 RPC
  • 크로스 플랫폼 지원 (iOS/Android)
  • 보안 메시지 시리얼라이제이션
  • Flutter와의 간편한 통합
  • 오픈소스이며 적극적으로 유지 관리되고 있습니다

적합한 대상

  • Flutter를 사용하는 모바일 앱 개발자
  • 앱 간 통신이 필요한 앱
  • 안전한 딥 링크 워크플로를 구현하는 개발자
  • 경량 RPC 대안이 필요한 프로젝트
  • 모듈형 또는 마이크로 프론트엔드 아키텍처를 구축하는 팀

고려 사항

  • 대상 플랫폼에서 올바른 딥 링크 구성이 필요합니다
  • 모바일 및 데스크톱 플랫폼에 한정 (웹 없음)
  • 올바른 URL 스킴 설정에 따라 달라집니다
  • 민감한 데이터에 대해 추가 보안 조치가 필요할 수 있습니다
  • 고주파 또는 저지연 통신에 적합하지 않습니다

원본 README

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

Deeplink RPC

A RPC-via-deeplink communication library coded in Dart. This is dedicated to Flutter mobile applications (iOS / Android).

Protocol

Deeplink codec

Deeplink messages are appended to the deeplink URI. Because of that, there are limitations in the available formatting.

To get it working, the message is encoded that way :

                     +--------------+   +------+   +-----------+
method_payload :     | Json Message |-> | gzip |-> | base64Url |
                     +--------------+   +------+   +-----------+


Deeplink Url : `<scheme>://<host>/<method_name>/<method_payload>`

Example :

                     +--------------------------+      +----------------------------------------------------------------+
method_payload :     | { "param1" : "a_value" } |----> | "H4sIAAAAAAAAA6tWUCpILErMNVRSsFJQSowvS8wpTVVSqAUAhIgKchgAAAA=" |
                     +--------------------------+      +----------------------------------------------------------------+


Deeplink Url : `scheme://host/a_method/H4sIAAAAAAAAA6tWUCpILErMNVRSsFJQSowvS8wpTVVSqAUAhIgKchgAAAA=`

Request formatting

Requests payload are encapsulated in a JSON-RPC 2.0 message.

{
  "id": Number,                     // An unique client-generated integer identifying the request
  "replyUrl": String,               // Deeplink URL to which send the invokation result. This should be a Deeplink URL handled by the DApp.
  "params": {
    "origin": {
      "name": String,               // Human readable identifier of the DApp
      "url": String | undefined,    // URL of the DApp
      "logo": Base64 | undefined,   // Logo of the DApp 
    },
    "version": 2,                   // Version of the DApp API
    "payload": Object,              // Method parameters
  }
}
Success Response formatting
{
  "id": Number,                     // The request identifier
  "result":  Object,                // Result payload
}
Failure Response formatting
{
  "id": Number,                     // The request identifier
  "failure": {
    "code": Number,                 // Error code
    "message": String | undefined,  // Error description
    "data": Object | undefined,     // Error data
  },
}

Usage

Server - listening to incoming requests
/// 1. Enable deeplinking for your application (https://docs.flutter.dev/development/ui/navigation/deep-linking)

/// 2. Declare the deeplink-rpc receiver
/// When a RPC call <scheme>://a_rpc_command/<payload> is received, the payload is decoded
/// and transmitted to the `handle` method.
final _deeplinkRpcServer = DeeplinkRpcServer()
    ..registerHandler(
      DeeplinkRpcRequestHandler(
        route: const DeeplinkRpcRoute('a_rpc_command'),
        handle: (request) {
            log('Command received');
        }
      ),
    );


class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DeeplinkRPC Demo',
      home: const SendForm(),
      onGenerateRoute: (settings) {
        /// 3. Listen to incoming deeplink requests
        if (_deeplinkRpcServer.handleRoute(settings.name)) return;

        // ... do other route generation stuffs here.
        return null;
      },
    );
  }
}
Client - Sending requests and listening for responses
/// 1. Enable deeplinking for your application (https://docs.flutter.dev/development/ui/navigation/deep-linking)
/// It is necessary to receive responses.

/// 2. Declare the deeplink-rpc client
/// When a RPC call <scheme>://a_rpc_command/<payload> is received, the payload is decoded
/// and transmitted to the `handle` method.
final _deeplinkRpcClient = DeeplinkRpcClient();

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DeeplinkRPC Demo',
      onGenerateRoute: (settings) {
        /// 3. Listen to incoming deeplink requests
        if (_deeplinkRpcClient.handleRoute(settings.name)) return;

        // ... do other route generation stuffs here.
        return null;
      },
      home: Scaffold(
        floatingActionButton: FloatingActionButton(
          child: const Icon(Icons.send),
          onPressed: () async {
            final response = await _deeplinkRpcClient.send(
              timeout: const Duration(seconds: 5),
              request: DeeplinkRpcRequest(
                requestUrl: 'serverapp://server.app/request_endpoint',
                replyUrl: 'clientapp://client.app/reply_endpoint',
                params: {
                  'param1': 'value1',
                  'param2': 'value2',
                },
              ),
            );

            response.map(
              failure: (failure) {
                log(
                  'RPC request failed',
                  error: failure,
                );
                ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(
                      content: Text(failure.message ?? "An error occured")),
                );
              },
              success: (result) {
                log(
                  'RPC request succeed : ${json.encode(result)}',
                );
                ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(content: Text(json.encode(result))),
                );
              },
            );
          },
        ),
        body: const SafeArea(
          child: Padding(
            padding: EdgeInsets.all(8.0),
            child: Center(
              child: Text('Client example'),
            ),
          ),
        ),
      ),
    );
  }
}

카테고리

의존성

의존성 목록 6 개

소스 저장소

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