react-native-background-timer icon indicating copy to clipboard operation
react-native-background-timer copied to clipboard

Background timer stopped after 30 seconds on iOS 13.3 & 13.3.1

Open iamtharin opened this issue 5 years ago • 19 comments

In iOS 13.3 & 13.3.1, when the count down timer is running in the background, it will be paused after 30s.

  1. Start a 60s count down timer in the foreground.
  2. After 10s, Put the app in the background (at 50s).
  3. Wait for 40s, while the app is in the background.
  4. Come to the foreground back.
  5. The count down timer starts to run from 20s but expected to be run from 10s.

Guys... Do you have any idea?

iamtharin avatar Feb 21 '20 09:02 iamtharin

@iamtharin I have fixed this with the following solution.

<key>UIBackgroundModes</key>
<array>
  <string>audio</string>
</array>

Add this in Info.Plist of your project and it will work

Zilleabbas10 avatar Feb 21 '20 20:02 Zilleabbas10

@Zilleabbas10 We have already added it but the issue is there :(

iamtharin avatar Feb 24 '20 04:02 iamtharin

it doesn't work on iOS 12.1.4

my code:

 import React, { Component } from 'react';
 import {
 SafeAreaView,
  Text,
  StatusBar,
 TouchableHighlight,
 Alert,
 } from 'react-native';
  import BackgroundTask from 'react-native-background-task'
  import queueFactory from 'react-native-queue';
  import { Notifications } from "react-native-notifications";
  import BackgroundTimer from 'react-native-background-timer';

  export default class App extends Component {
   constructor(props) {
     super(props);
     this.state = {
       isOpened: false,
       queue: null
     }

    Notifications.registerRemoteNotifications();

 Notifications.events().registerNotificationReceivedForeground((notification: Notification, completion: (response: NotificationCompletion) => void) => {
  Alert.alert('Bildirimler gelecek', '', [{ text: 'Kapat' }]);
  console.warn("Notification Received - Foreground", notification.payload);
  // Calling completion on iOS with `alert: true` will present the native iOS inApp notification.
  completion({alert: true, sound: true, badge: true});
    });

Notifications.events().registerNotificationOpened((notification: Notification, completion: () => void, action: NotificationActionResponse) => {
  Alert.alert('bildirim açıldı!');
  console.warn("Notification opened by device user", notification.payload);
  completion();
});
    
    Notifications.events().registerNotificationReceivedBackground((notification: Notification, completion: (response: NotificationCompletion) => void) => {
  console.log("Notification Received - Background", notification.payload);

  // Calling completion on iOS with `alert: true` will present the native iOS inApp notification.
  completion({alert: true, sound: true, badge: false});
  });
   }

   componentDidMount() {
     BackgroundTimer.start();
     setInterval(() => {
       return Notifications.postLocalNotification({
         body: "Tahmini 15 dk sonra gelen bildirim: 10:15",
         title: "Local Notification Title",
         sound: "chime.aiff",
         silent: false,
         category: "SOME_CATEGORY",
         userInfo: { }
       }, 3);
     }, 1000 * 10);
     BackgroundTimer.stop();
   }


   render() {
     return (
       <>
       <StatusBar barStyle="dark-content" />
       <SafeAreaView style={{ flex: 1, alignItems: 'center', justifyContent: 'center', }}>
           <Text>Deneme</Text>
       </SafeAreaView>
       </>
     )
   }
 }

gunduzcihat avatar Feb 27 '20 11:02 gunduzcihat

@gunduzcihat @iamtharin did you guys find any solution for iOS?

tal987 avatar May 06 '20 13:05 tal987

We had to do a work around. What we did was, playing a silent audio while the app is in the background mode. This worked as expected.

On Wed, May 6, 2020, 6:49 PM tal987 [email protected] wrote:

@gunduzcihat https://github.com/gunduzcihat @iamtharin https://github.com/iamtharin did you guys find any solution for iOS?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-624644084, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOSY6LWO7RL4WCJPG57ZR3LRQFPVLANCNFSM4KY7N35A .

iamtharin avatar May 06 '20 13:05 iamtharin

@iamtharin can you show how did you do that please? how did you play silent sound?

tal987 avatar May 06 '20 13:05 tal987

@iamtharin this is what you did? BackgroundTimer.runBackgroundTimer(() => { var fakeSound = new Sound('', Sound.MAIN_BUNDLE, (error) => { if (error) { console.log('failed to load the sound'); } }) fakeSound.play((success) => { if (success) { } else { } }); console.log("App is Hii") }, 3000*10);

tal987 avatar May 06 '20 14:05 tal987

Any news on this issue?

Also reproduced on iOS 12.4.8

jknap avatar Sep 07 '20 22:09 jknap

Nothing yet?

d0xi5 avatar Sep 29 '20 15:09 d0xi5

@iamtharin I have fixed this with the following solution.

<key>UIBackgroundModes</key>
<array>
  <string>audio</string>
</array>

Add this in Info.Plist of your project and it will work

This worked for me, very strange, because i set location before but didn't work

thanhluantl2304 avatar Oct 09 '20 07:10 thanhluantl2304

+1, stop after 30 seconds

nguyentrannhan avatar Nov 17 '20 11:11 nguyentrannhan

@iamtharin I have fixed this with the following solution.

<key>UIBackgroundModes</key>
<array>
  <string>audio</string>
</array>

Add this in Info.Plist of your project and it will work

This worked for me, very strange, because i set location before but didn't work

I've tried this and got this message back from Apple.

Your app declares support for audio in the UIBackgroundModes key in your Info.plist, but we were unable to play any audible content when the app was running in the background.

gpminsuk avatar Dec 11 '20 05:12 gpminsuk

We had to do a work around. What we did was, playing a silent audio while the app is in the background mode. This worked as expected. On Wed, May 6, 2020, 6:49 PM tal987 @.***> wrote: @gunduzcihat https://github.com/gunduzcihat @iamtharin https://github.com/iamtharin did you guys find any solution for iOS? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#191 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOSY6LWO7RL4WCJPG57ZR3LRQFPVLANCNFSM4KY7N35A .

helo , how did you apply silent audio in bg. pls help me i am stuck in this issue last two week, can you give your contact or pls call on 8423087803, i need your helo

Amar-RN avatar Aug 12 '21 06:08 Amar-RN

When the user is going to the background, a silent audio will be played until the user comes back from the background to the foreground. That's all what we did.

On Thu, Aug 12, 2021, 11:57 AM Amar-RN @.***> wrote:

We had to do a work around. What we did was, playing a silent audio while the app is in the background mode. This worked as expected. … <#m_1910379230135917114_> On Wed, May 6, 2020, 6:49 PM tal987 @.***> wrote: @gunduzcihat https://github.com/gunduzcihat https://github.com/gunduzcihat @iamtharin https://github.com/iamtharin https://github.com/iamtharin did you guys find any solution for iOS? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#191 (comment) https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-624644084>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOSY6LWO7RL4WCJPG57ZR3LRQFPVLANCNFSM4KY7N35A .

helo , how did you apply silent audio in bg. pls help me i am stuck in this issue last two week, can you give your contact or pls call on 8423087803, i need your helo

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-897382922, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOSY6LQRONGQ2KVUKISUI6TT4NSW3ANCNFSM4KY7N35A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

iamtharin avatar Aug 12 '21 06:08 iamtharin

can u share your contact no ? please please

if you dont mind.

On Thu, 12 Aug 2021 at 12:14, iamtharin @.***> wrote:

When the user is going to the background, a silent audio will be played until the user comes back from the background to the foreground. That's all what we did.

On Thu, Aug 12, 2021, 11:57 AM Amar-RN @.***> wrote:

We had to do a work around. What we did was, playing a silent audio while the app is in the background mode. This worked as expected. … <#m_1910379230135917114_> On Wed, May 6, 2020, 6:49 PM tal987 @.***> wrote: @gunduzcihat https://github.com/gunduzcihat https://github.com/gunduzcihat @iamtharin https://github.com/iamtharin https://github.com/iamtharin did you guys find any solution for iOS? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#191 (comment) < https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-624644084

, or unsubscribe

https://github.com/notifications/unsubscribe-auth/AOSY6LWO7RL4WCJPG57ZR3LRQFPVLANCNFSM4KY7N35A

.

helo , how did you apply silent audio in bg. pls help me i am stuck in this issue last two week, can you give your contact or pls call on 8423087803, i need your helo

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-897382922 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AOSY6LQRONGQ2KVUKISUI6TT4NSW3ANCNFSM4KY7N35A

. Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android < https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-897389943, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATU7BUGXA66KWTS67LUG7OTT4NUUFANCNFSM4KY7N35A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

Amar-RN avatar Aug 12 '21 07:08 Amar-RN

Please call on 8423087803 or what app i need your help.

On Thu, 12 Aug 2021 at 12:55, Amar Gupta @.***> wrote:

can u share your contact no ? please please

if you dont mind.

On Thu, 12 Aug 2021 at 12:14, iamtharin @.***> wrote:

When the user is going to the background, a silent audio will be played until the user comes back from the background to the foreground. That's all what we did.

On Thu, Aug 12, 2021, 11:57 AM Amar-RN @.***> wrote:

We had to do a work around. What we did was, playing a silent audio while the app is in the background mode. This worked as expected. … <#m_1910379230135917114_> On Wed, May 6, 2020, 6:49 PM tal987 @.***> wrote: @gunduzcihat https://github.com/gunduzcihat https://github.com/gunduzcihat @iamtharin https://github.com/iamtharin https://github.com/iamtharin did you guys find any solution for iOS? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#191 (comment) < https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-624644084

, or unsubscribe

https://github.com/notifications/unsubscribe-auth/AOSY6LWO7RL4WCJPG57ZR3LRQFPVLANCNFSM4KY7N35A

.

helo , how did you apply silent audio in bg. pls help me i am stuck in this issue last two week, can you give your contact or pls call on 8423087803, i need your helo

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-897382922 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AOSY6LQRONGQ2KVUKISUI6TT4NSW3ANCNFSM4KY7N35A

. Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android < https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-897389943, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATU7BUGXA66KWTS67LUG7OTT4NUUFANCNFSM4KY7N35A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

Amar-RN avatar Aug 12 '21 08:08 Amar-RN

hey,

How did you do , can u please share code.

On Thu, 12 Aug 2021 at 12:14, iamtharin @.***> wrote:

When the user is going to the background, a silent audio will be played until the user comes back from the background to the foreground. That's all what we did.

On Thu, Aug 12, 2021, 11:57 AM Amar-RN @.***> wrote:

We had to do a work around. What we did was, playing a silent audio while the app is in the background mode. This worked as expected. … <#m_1910379230135917114_> On Wed, May 6, 2020, 6:49 PM tal987 @.***> wrote: @gunduzcihat https://github.com/gunduzcihat https://github.com/gunduzcihat @iamtharin https://github.com/iamtharin https://github.com/iamtharin did you guys find any solution for iOS? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#191 (comment) < https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-624644084

, or unsubscribe

https://github.com/notifications/unsubscribe-auth/AOSY6LWO7RL4WCJPG57ZR3LRQFPVLANCNFSM4KY7N35A

.

helo , how did you apply silent audio in bg. pls help me i am stuck in this issue last two week, can you give your contact or pls call on 8423087803, i need your helo

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-897382922 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AOSY6LQRONGQ2KVUKISUI6TT4NSW3ANCNFSM4KY7N35A

. Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android < https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ocetnik/react-native-background-timer/issues/191#issuecomment-897389943, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATU7BUGXA66KWTS67LUG7OTT4NUUFANCNFSM4KY7N35A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

Amar-RN avatar Aug 12 '21 08:08 Amar-RN

any update ?

akimabs avatar Dec 06 '21 08:12 akimabs

hey, i have the same error, stop working after 30sec

lowright avatar Oct 23 '23 00:10 lowright