Skip to content

Latest commit

 

History

History
82 lines (51 loc) · 3.68 KB

CONTRIBUTING.md

File metadata and controls

82 lines (51 loc) · 3.68 KB

Contributing guide

In this guide, I try to help you contribute feature requests, bug reports, bug fixes and features to this project. Take a look at useful tips to help you investigate or learn the package a bit better.

Setup

  • Install mise
  • Run tasks with mise, e.g. mise lint. See all tasks in mise.toml.
  • Make changes to code
  • To make changes to the interface between Dart and platforms (e.g. iOS/Android/macOS),
    • change push/pigeons/push_api.dart and regenerate the files by running mise codegen

Release

  • Update pubspec.yaml with new version
  • Update CHANGELOG.md
  • Publish with mise publish

Useful commands and resources

  • To publish, run flutter pub publish in specific folders (and all other packages that depend on it, starting with the leaf packages that have no dependencies)

Android

  • Nice logs in command line: pidcat com.example.app
  • Check if app process is runnning watch -n 1 'adb -s emulator-5554 shell ps -A | grep push'
    • Even pressing down on app icon (launching popup menu) launches the app
  • Kill an application process: put the app in the background, then run adb shell am kill uk.orth.push.example
  • Take screenshot with scrcpy: adb exec-out screencap -p > "screenshot_$(date +%s).png"
  • Reboot emulator :adb -e reboot

iOS

  • Install SwiftFormat: brew install swiftformat
  • Format files: run make format or swiftformat .

Types of contributions

I may create templates for these in the future.

Feature requests

Please create an issue describing what features you want. If you have any idea on the implementation, that would be helpful.

Bug report

Please provide as much information as possible. For example, the state of the application when the push notification is received.

Bug fixes

You can also contribute bug fixes yourself, by forking this repo on GitHub, and opening a pull request. I will try to take a look, and keep an eye on GitHub notifications.

Features

You can give also contribute feature implementations to the project. If the feature is relatively large or complex, discussing it in a GitHub issue can help you think through the feature and contribute higher quality code.

Concepts

Data types

iOS and Android have different structures for push notifications. Android's RemoteMessage has a lot more metadata than iOS's userInfo dictionary.

To add more types this package's RemoteMessage type, you need to do 2 things:

  • Add more fields to the data type in pigeons/push_api.dart
  • Fill this field on the platform side:
    • On Android, in Serialization.kt, extract more of RemoteMessage into the Map. Make sure that the keys you use for the map correspond to the fields in RemoteMessage.

Pigeon

Pigeon is used to generate code which serializes and deserializes data, including method calls and types between Flutter and the Host.

  • Implementation of methods called from the other side are called PushXHandlers, for example PushHostHandlers and PushFlutterHandlers.
  • Instances used to call methods on the other side of the serialization barrier have been called: PushXApi, for example PushHostApi and PushFlutterApi.

To (re)generate pigeon files:

  • Run ./scripts/codegen.sh

Manual adjustments

  • When re-generating Pigeon code, it might break. I once made 1 small adjustment to the generated code to fix the issue reported in flutter/flutter#101515. This is not required anymore.