jpush / jpush/jpush-react-native

推荐iOS的setBadge方法加入本地设置角标的功能

Open
#692 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.4k
Forks
348
PR merge metrics
No merged PRs in 30d

Description

你的运行环境

  • 插件版本: 2.5.10
  • react-native 版本:0.61.2

期望效果

setBadge设置本地角标效果,也没有提供resetBadge方法,目前无法清除本地角标

实际效果

无法清除本地角标

重现步骤

Debug logs

包括 Android 或 iOS 的日志:

原因

修改setBadge加入本地角标设置

//badge 角标
RCT_EXPORT_METHOD(setBadge:(NSDictionary *)params)
{
    if(params[BADGE]){
        NSNumber *number = params[BADGE];
        [JPUSHService setBadge:[number integerValue]];
        // ADD THIS
        [[UIApplication sharedApplication] setApplicationIconBadgeNumber:[number integerValue]];
    }
}

我看JPUSHServer.h有如下注释

 * @discussion 本接口不会改变应用本地的角标值.
 * 本地仍须调用 UIApplication:setApplicationIconBadgeNumber 函数来设置脚标.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the iOS implementation of the RCT_EXPORT_METHOD(setBadge:) entry point and read the JPUSHServer.h note about local badge values. Verify how UIApplication setApplicationIconBadgeNumber should be integrated so the local badge can be set or cleared, then confirm the exposed behavior matches the requested setBadge and reset functionality.

Written by the indexing model from the issue text.

Assessment

Tech stack
objective-c, react-native
Domain
mobile-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.