Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

基于Kotlin重构Android插件代码并支持多Flutter engine和更精准的result回调管理 #282

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

techwn
Copy link

@techwn techwn commented Jun 28, 2021

现有JPushPlugin的职责太多

  • onMethodCall调用处理
  • 管理各种回调的缓存
  • 基于static的持有JPushPlugin instance,并在每次attach之后被新的plugin实例覆盖,这样是不合理的,存在潜在bug
  • 过多的isDartReady,instance = null, context = null相关判断, 显得比较混乱
  • 持有静态内部类JPushReceiver,并和宿主基于static的JPushPlugin instance进行数据交互

所以拆分JPushPlugin的缓存和回调分发功能到单例类:JPushCallbackDispatcher。
JPushPlugin专注于onMethodCall的dart端代码调用处理。
另外删除静态内部类JPushPlugin$JPushReceiver,相关功能合并到JPushEventReceiver

架构变化如下:
Push Notification Setting (1)

Comment on lines +16 to +30
Pair(JPushInterface.EXTRA_EXTRA, notificationExtras),
Pair(JPushInterface.EXTRA_ALERT_TYPE, notificationAlertType),
Pair(JPushInterface.EXTRA_NOTIFICATION_ID, notificationId),
Pair(JPushInterface.EXTRA_MSG_ID, msgId),
Pair(JPushInterface.EXTRA_ALERT, notificationContent),
Pair(JPushInterface.EXTRA_NOTIFICATION_TITLE, notificationTitle),
Pair(JPushInterface.EXTRA_NOTI_TYPE, notificationType),
Pair(JPushInterface.EXTRA_BIG_TEXT, notificationBigText),
Pair(JPushInterface.EXTRA_INBOX, notificationInbox),
Pair(JPushInterface.EXTRA_BIG_PIC_PATH, notificationBigPicPath),
Pair(JPushInterface.EXTRA_NOTI_PRIORITY, notificationPriority),
Pair(JPushInterface.EXTRA_NOTI_CATEGORY, notificationCategory),
Pair(JPushInterface.EXTRA_NOTIFICATION_SMALL_ICON, notificationSmallIcon),
Pair(JPushInterface.EXTRA_NOTIFICATION_LARGET_ICON, notificationLargeIcon),
Pair(JPushInterface.EXTRA_TYPE_PLATFORM, platform),
Copy link
Author

@techwn techwn Jun 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块是基于41项JPushInterface. EXTRA_XXX和NotificationMessage相关的属性名字整理出来的15条,其中删除了现有官方要求忽略的几条,如有错漏请补充(我们内部其实只会用到第一条)。

Comment on lines +5 to 7
<receiver android:name="com.jiguang.jpush.JPushEventReceiver"
android:enabled="true"
android:exported="false">
Copy link
Author

@techwn techwn Jun 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的修改是基于官方文档,添加enabled和exported属性以消除警告

@techwn techwn changed the title 基于Kotlin重构Android插件代码并支持多Flutter engine和更精准的result回调 基于Kotlin重构Android插件代码并支持多Flutter engine和更精准的result回调管理 Jul 1, 2021
@AlexV525
Copy link

放弃吧...你看他们鸟你吗...这就是你国内上游厂商🤮

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants