Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Memory Leak when call push.on('registration'. so Push Plugin register called not called #743

Closed
kntmrkm opened this issue Mar 23, 2016 · 3 comments

Comments

@kntmrkm
Copy link

kntmrkm commented Mar 23, 2016

I have already confirmed that push notification works in my env.
This means my code is almost correct.

But, sometimes application crash with memory leak.
it occurs randomly.

Log without memory leak

2016-03-23 14:01:13.224 App[8280:3054328] Apache Cordova native platform version 4.0.1 is starting.
2016-03-23 14:01:13.338 App[8280:3054328] Ionic Core: plugins are ready
2016-03-23 14:01:13.708 App[8276:3053868] initializePushNotification
2016-03-23 14:01:13.732 App[8276:3053914] **Push Plugin register called**

line 4 is correct behavior.

And next build (I validate this with xcode build and real device.)

Log with memory leak

2016-03-23 14:01:47.338 App[8280:3054328] Ionic Core: plugins are ready
2016-03-23 14:01:47.338 App[8280:3054328] initializePushNotification
2016-03-23 14:02:26.940 App[8280:3054328] Received memory warning.
2016-03-23 14:02:27.469 App[8280:3054328] Received memory warning.
Message from debugger: Terminated due to memory issue

Push Plugin register called not called.

I'm using ionic framework.

Cordova CLI: 6.0.0
Gulp version:  CLI version 3.9.1
Gulp local:   Local version 3.9.0
Ionic Version: 1.2.4
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: 1.8.5
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v5.3.0
Xcode version: Xcode 7.2.1 Build version 7C1002
  • Apache cordova ios version is 4.0.1
  • iOS version is 9.2.1

My code is

function initializePushNotification() {
  console.log('initializePushNotification');

  // PUSH Notificaiton
  try {
    var push = PushNotification.init({
      android: {
        senderID: "XXX"
      },
      ios: {
        alert: "true",
        badge: "true",
        sound: "true"
      },
      windows: {}
    });

  } catch(e) {
    console.log(e);
  }

  try {
    push.off('registration', function(data) {});
    push.off('notification', function(data) {});
    push.off('error', function(data) {});

    push.on('registration', function(data) {
      // Push Plugin register called
      console.log('PushNotification registration: ' + data.registrationId);
    });
  } catch(e) {
    console.log(e);
  }
}

$ionicPlatform.ready(function() {
  // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard for form inputs)
  if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
    cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
  }
  if (window.StatusBar) {
    StatusBar.styleDefault();
  }

  initializePushNotification();
});

thanks

@kntmrkm
Copy link
Author

kntmrkm commented Mar 23, 2016

I solved this issue.

But I did not found cause of memory leak.

I have upgrade cordova-ios version from 4.0.1 to 4.1.0.

Then, there is no problem.

@kntmrkm kntmrkm closed this as completed Mar 23, 2016
@marconvcm
Copy link

I had the same issue and I don't know the cause, if anyone knows please advise.

@lock
Copy link

lock bot commented Jun 4, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants