Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
110 stars 139 forks source link

Docs/Behavior for default IOS_FOREGROUND_ALERT_TYPE #203

Closed zarko-tg closed 7 years ago

zarko-tg commented 8 years ago

http://docs.pushwoosh.com/docs/customizing-cordova-plugin currently says:

IOS_FOREGROUND_ALERT_TYPE

BANNER – default value, displays banner in-app alert ALERT – alert notification NONE – do not display a notification when the app is in the foreground (default setting)

If you read the bolded text above, which one is the default, BANNER or NONE?

DimanAM commented 8 years ago

NONE is set by default. The ambiguous documentation has been fixed. Thanks.

zarko-tg commented 8 years ago

Thanks for addressing the issue with the documentation.

Now, what I noticed is that if the iOS plugin variable IOS_FOREGROUND_ALERT_TYPE is not explicitly specified/used by the developer, the plugin defaults to BANNER (and not NONE). This is experienced when the app is in the foreground and instead of custom handling of the push notification you see a BANNER instead.

Great if you or any other developer can confirm this unexpected behavior/bug.

zarko-tg commented 7 years ago

Ping @DimanAM.

DimanAM commented 7 years ago

NONE is default value for IOS_FOREGROUND_ALERT_TYPE preference https://github.com/Pushwoosh/pushwoosh-phonegap-plugin/blob/master/plugin.xml#L20. This value is then added to Info.plist file: https://github.com/Pushwoosh/pushwoosh-phonegap-plugin/blob/master/plugin.xml#L139

If something goes wrong and Pushwoosh_ALERT_TYPE is not set in Info.plist the BANNER value will be used as per https://github.com/Pushwoosh/pushwoosh-ios-sdk/blob/master/Documentation/InfoPlist.md.

This may happen for example on the latest cordova version if you:

cordova plugin add pushwoosh-cordova-plugin --save
rm -rf plugins/
cordova platform add ios

The problem is that cordova sets all unspecified preferences to undefined not the default values from plugin.xml when you save them to config:

<plugin name="pushwoosh-cordova-plugin" spec="~6.2.1">
    <variable name="LOG_LEVEL" value="undefined" />
    <variable name="IOS_FOREGROUND_ALERT_TYPE" value="undefined" />
    <variable name="ANDROID_FOREGROUND_PUSH" value="undefined" />
</plugin>

So please pay close attention to what preferences are stored in your config.xml.

amitparrikar commented 7 years ago

@zarko-tg any luck with this issue? I ran into the similar issue Error: One of your plugins is missing the following variables: "LOG_LEVEL, IOS_FOREGROUND_ALERT_TYPE, ANDROID_FOREGROUND_PUSH"

I have registered my plugin pushwoosh-cordova-plugin with: cordova plugin add pushwoosh-cordova-plugin --variable LOG_LEVEL="DEBUG" --variable IOS_FOREGROUND_ALERT_TYPE="NONE" --variable ANDROID_FOREGROUND_PUSH="false" —save

and my config.xml is `

    <variable name="IOS_FOREGROUND_ALERT_TYPE" value="NONE" />
    <variable name="ANDROID_FOREGROUND_PUSH" value="false" />
</plugin>`

@zarko-tg @DimanAM Any Help ?

zarko-tg commented 7 years ago

@amitparrikar I has to manually specify the wanted values in our config.xml, like:

  <plugin name="pushwoosh-cordova-plugin" spec="6.4.0">
    <variable name="IOS_FOREGROUND_ALERT_TYPE" value="NONE"/>
    <variable name="ANDROID_FOREGROUND_PUSH" value="false"/>
  </plugin>
viridanti commented 7 years ago

The issue is related to Cordova itself.