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

PushNotificationIOS.setApplicationIconBadgeNumber() doesn't work if the app is in background state. #22740

Closed
3 tasks done
JulienUsson opened this issue Dec 20, 2018 · 2 comments
Labels
API: PushNotificationIOS Bug Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@JulienUsson
Copy link

Environment

 React Native Environment Info:
    System:
      OS: macOS 10.14.2
      CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
      Memory: 40.18 MB / 8.00 GB
      Shell: 5.6.2 - /usr/local/bin/zsh
    Binaries:
      Node: 11.0.0 - ~/.nvm/versions/node/v11.0.0/bin/node
      Yarn: 1.12.1 - ~/.nvm/versions/node/v11.0.0/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v11.0.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 23, 24, 25, 26, 27
        Build Tools: 23.0.1, 24.0.3, 25.0.2, 26.0.1, 26.0.2, 27.0.3
    IDEs:
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3 
      react-native: 0.57.8 => 0.57.8 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Description

PushNotificationIOS.setApplicationIconBadgeNumber() doesn't work on IOS if the app is in background state.

Reproducible Demo

import React, {Component} from 'react'
import {PushNotificationIOS, Text, View} from 'react-native'
import OneSignal from 'react-native-onesignal'

export default class App extends Component {
    state = {
        notification: null
    }

    componentDidMount() {
        OneSignal.init("token", {kOSSettingsKeyAutoPrompt: true})
        OneSignal.inFocusDisplaying(0)
        OneSignal.addEventListener('received', this.onReceived)
    }

    componentWillUnmount() {
        OneSignal.removeEventListener('received', this.onReceived)
    }

    onReceived = async notification => {
        PushNotificationIOS.setApplicationIconBadgeNumber(1)  // doesn't work in background
        this.setState({notification}) // work in background
    }

    render() {
        return (
            <View>
                <Text>{JSON.stringify(this.state.notification)}</Text>
            </View>
        )
    }
}
`
``
@cpojer
Copy link
Contributor

cpojer commented Feb 15, 2019

This issue has been moved to react-native-push-notification/ios#5.

@nguyenvanphuc2203
Copy link

same issue!

@facebook facebook locked as resolved and limited conversation to collaborators Feb 15, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Feb 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API: PushNotificationIOS Bug Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants