pushandplay / cordova-plugin-apprate

This plugin provide the "rate this app" functionality into your Cordova/Phonegap application
Apache License 2.0
299 stars 192 forks source link

Crash APP iOS #212

Open dlaudh opened 6 years ago

dlaudh commented 6 years ago

Intro

Hello, when compile and call method this.appRate.promptForRating(true); the app doesn't work, crash and close.

My ionic info

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-plugin-proxy : 1.5.8
@ionic/cli-utils        : 1.19.2
ionic (Ionic CLI)       : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0 

local packages:

@ionic/app-scripts : 3.1.9
Cordova Platforms  : ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

System:

ios-deploy : 1.9.2 
Node       : v10.2.1
npm        : 6.1.0 
OS         : macOS High Sierra
Xcode      : Xcode 9.4 Build version 9F1027a 

Misc:

backend : legacy

How to fill preferences

    this.appRate.preferences.displayAppName = 'Example';
    this.appRate.preferences.usesUntilPrompt = 5;
    this.appRate.preferences.promptAgainForEachNewVersion = false;

    this.appRate.preferences.storeAppURL = {
      ios: '*********', // I remove this for no show my app id in this post
      android: 'market://details?id=*****' // I remove this for no show my app id in this post
    };

    this.appRate.preferences.customLocale = {
      title : "Example",
      message : "msg",
      cancelButtonLabel : "cancel",
      laterButtonLabel :  "no",
      rateButtonLabel :   "rate"
    }

    // then in another function call
    this.appRate.promptForRating(true);

Error in Xcode console

2018-06-15 14:02:22.026900-0300 APP[642:205905] -[NSNull length]: unrecognized selector sent to instance 0x1b76f0878 2018-06-15 14:02:22.034700-0300 APP[642:205905] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x1b76f0878' First throw call stack: (0x18537ad8c 0x1845345ec 0x185388098 0x1853805c8 0x18526641c 0x18f1b99ac 0x18f1b98b0 0x18f1b97e8 0x100349ca4 0x10034aa90 0x100376a44 0x100376338 0x10036c598 0x1003793fc 0x10036c3f8 0x185dc60ec 0x185323404 0x185322c2c 0x18532079c 0x185240da8 0x187225020 0x18f25d758 0x1001a852c 0x184cd1fc0) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

Mobiletainment commented 6 years ago

same problem here. It only occurs in the release build though.

dlaudh commented 6 years ago

@Mobiletainment how sure are you? Do you have any proof?

Add more detail of code

[alertController addAction:[UIAlertAction actionWithTitle:[buttons objectAtIndex:n] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action)

In Objetive-C broken in this line

Thanks

dlaudh commented 6 years ago

Hello guys, I solve this problem downloading version to @1.2.0

Regrads

kurtiev commented 6 years ago

For me the same :/ http://prntscr.com/k0t55l But it works on iOS 10.3 and not on iOS 11.4....
Any news with this issue? Downgrade to 1.2.0 - also doesn't work at all, and xCode doesn't give any exceptions, like with latest(1.4.0) version On Android didn't test.

dlaudh commented 6 years ago

Hi @kurtiev,

On android it does not matter the version works perfectly it's only on ios.

My solution does not work, sorry

kurtiev commented 6 years ago

@DualH let to know please, if you will find alternative solution. Thanks.

Update: It's to be a strange, but everything is OK on emulator iOS 11.4, so my issue only with real device. Device and emulator are same: iPhone 7, 11.4

kurtiev commented 6 years ago

@DualH Sorry, issue is fixed. Just do not laugh at me, the issue was that i was using: ios: '<app_id>' instead of: ios: 'app_id'. Android the same, without "<>" must be.

dlaudh commented 6 years ago

@kurtiev, yes the correct way of implement is ios: '213123' ↑ numbers random haha.

In my case is different because the problem start when I update to Ionic 3 and Angular 5

Regards.

petrot commented 6 years ago

Same problem here..

I just recognized that this._appRate.preferences is null, when I try to add custom parameters.

ralphcode commented 6 years ago

I've been using this plugin for a while and got stuck on this. Looks like the plugin now requires you to supply a noButtonLabel and yesButtonLabel in your customLocale.

The Locales.getLocale() method used in showDialog (AppRate.js) does not check and provide default values for these. With your example above, when simpleMode === false, it calls; navigator.notification.confirm(localeObj.appRatePromptMessage, promptForAppRatingWindowButtonClickHandler, localeObj.appRatePromptTitle, [localeObj.noButtonLabel, localeObj.yesButtonLabel]);

Which evaluates to; navigator.notification.confirm('Msg', Func, 'Example', [undefined,undefined]); // Note undefined

The navigator.notification.confirm is actually what crashes the app as the button labels are undefined when passed back to native code.

For me at least, ensuring I've provided all of the custom locale properties (and specifically the no and yes button labels) has solved this;

AppRate.preferences.customLocale = {
  title: "Would you mind rating %@?",
  message: "It won’t take more than a minute and helps to promote our app. Thanks for your support!",
  cancelButtonLabel: "No, Thanks",
  laterButtonLabel: "Remind Me Later",
  rateButtonLabel: "Rate It Now",
  yesButtonLabel: "Yes!",
  noButtonLabel: "Not really",
  appRatePromptTitle: 'Do you like using %@',
  feedbackPromptTitle: 'Mind giving us some feedback?',
};
petrot commented 6 years ago

@Ralpharoo thanks, it solves my problem :)

I use simpleMode: true, so the appRatePromptTitle and feedbackPromptTitle properties are not necessarry.