distriqt / ANE-Parse

Provides access to the Parse SDK
https://airnativeextensions.com/extension/com.distriqt.Parse
Other
0 stars 0 forks source link

How to disable the alert-popup. #9

Closed simengjermundsen closed 9 years ago

simengjermundsen commented 9 years ago

How can I prevent the alert box showing up on iOS when receiving a push notification? I want to handle the notification myself.

marchbold commented 9 years ago

Not sure this is possible with Parse, have you seen an example somewhere?

simengjermundsen commented 9 years ago

Yes. It is definitely possible. I have used Parse in many native apps before.

In Objective-C this is the method that is responsible for opening the alert view: [PFPush handlePush:userInfo];

If it is removed then the alert will not show. This is usually implemented inside

The handlePush-method is only kind of a fallback/test in case the data from the push notification is not handle in any other way.

Greetings, Simen

  1. sep. 2015 kl. 11.48 skrev Michael notifications@github.com:

Not sure this is possible with Parse, have you seen an example somewhere?

— Reply to this email directly or view it on GitHub https://github.com/distriqt/ANE-Parse/issues/9#issuecomment-138254618.

simengjermundsen commented 9 years ago

Some more info:

https://www.parse.com/questions/pfpush-handlepush https://www.parse.com/questions/pfpush-handlepush

  1. sep. 2015 kl. 11.48 skrev Michael notifications@github.com:

Not sure this is possible with Parse, have you seen an example somewhere?

— Reply to this email directly or view it on GitHub https://github.com/distriqt/ANE-Parse/issues/9#issuecomment-138254618.

marchbold commented 9 years ago

Ah I see, I misunderstood what you meant.

This currently isn't possible with the ANE. We'll look into adding this in the next release.

simengjermundsen commented 9 years ago

Oh. Damn.

Then I cannot use it as it is now.

Please add this soon :) I cannot imagine many people sending push messages to only appear in a standard UIAlertView with a message? That seems kind of useless to me atleast…

Greetings, Simen

  1. sep. 2015 kl. 14.24 skrev Michael notifications@github.com:

Ah I see, I misunderstood what you meant.

This currently isn't possible with the ANE. We'll look into adding this in the next release.

— Reply to this email directly or view it on GitHub https://github.com/distriqt/ANE-Parse/issues/9#issuecomment-138282801.

marchbold commented 9 years ago

You should be able to control it with the payload of the notifications though?

If you don't want the alert to show just don't put an alert tag in the payload.

simengjermundsen commented 9 years ago

Oh. I thought the «alert» was the one that showed up as the title of the notification?

If I can send the notifications without the «alert» and still get all other bits working then everything is fine!

Simen

  1. sep. 2015 kl. 14.33 skrev Michael notifications@github.com:

You should be able to control it with the payload of the notifications though?

If you don't want the alert to show just don't put an alert tag in the payload.

— Reply to this email directly or view it on GitHub https://github.com/distriqt/ANE-Parse/issues/9#issuecomment-138285189.

simengjermundsen commented 9 years ago

But I cannot figure out how to do that… Any idea? Can I use some other parameter for the title of the notification? I am only able to display it using «alert»…

  1. sep. 2015 kl. 14.33 skrev Michael notifications@github.com:

You should be able to control it with the payload of the notifications though?

If you don't want the alert to show just don't put an alert tag in the payload.

— Reply to this email directly or view it on GitHub https://github.com/distriqt/ANE-Parse/issues/9#issuecomment-138285189.

marchbold commented 9 years ago

I believe something like this should work, leaving out the 'loc-key' value:

{
    "aps" : { 
        "alert" : {
            "title": "some title",
            "body": "message body"
        } 
    },
    "acme" : "foo"
}
simengjermundsen commented 9 years ago

Aha!

Seems like it might be working!

Thank you so much :)

Simen

  1. sep. 2015 kl. 14.43 skrev Michael notifications@github.com:

I believe something like this should work, leaving out the 'loc-key' value:

{ "aps" : { "alert" : { "title": "some title", "body": "message body" } }, "acme" : "foo" } — Reply to this email directly or view it on GitHub https://github.com/distriqt/ANE-Parse/issues/9#issuecomment-138287979.

simengjermundsen commented 9 years ago

Hmm… Sorry to bother you even more, but it does not seem to work anyway.

When sending «alert» as a string it shows the alert. When sending «alert» as an object with «title» and «body» i crashes the app as soon at it is trying to show the alert. I am pretty confident that it is not my handling of the data that causes this as all my functions are run before the crash happens.

Any way you could investigate this?

Is the ANE treating the «alert» as a string even if it is sent as an object or something?

Greetings, Simen

  1. sep. 2015 kl. 14.46 skrev Simen Øian Gjermundsen simen.gjermundsen@me.com:

Aha!

Seems like it might be working!

Thank you so much :)

Simen

  1. sep. 2015 kl. 14.43 skrev Michael <notifications@github.com mailto:notifications@github.com>:

I believe something like this should work, leaving out the 'loc-key' value:

{ "aps" : { "alert" : { "title": "some title", "body": "message body" } }, "acme" : "foo" } — Reply to this email directly or view it on GitHub https://github.com/distriqt/ANE-Parse/issues/9#issuecomment-138287979.

marchbold commented 9 years ago

That handling is internal to the Parse SDK.

I'll try and get an option to switch the default handling off today for you.

marchbold commented 9 years ago

Hi, I've added that option in for you now, you'll have to setup your application as follows:

Parse.service.setupApplication( PARSE_APP_ID, PARSE_CLIENT_ID, false );
Parse.service.register( false );
simengjermundsen commented 9 years ago

Brilliant! Thank you so much :)

Sendt fra min iPhone

Den 8. sep. 2015 kl. 00.37 skrev Michael notifications@github.com:

Hi, I've added that option in for you now, you'll have to setup your application as follows:

Parse.service.setupApplication( PARSE_APP_ID, PARSE_CLIENT_ID, false ); Parse.service.register( false ); — Reply to this email directly or view it on GitHub.

simengjermundsen commented 9 years ago

Hi again.

Sorry to bother you even more.

I have been testing for an hour ow, and I am completely unable to avoid having the app crash when opened from a Push Notification. When launched from before and then receiving a push there is no problem, but when opened by clicking a notification it crashes with no error.

Someting you can investigate? I have no idea where the error is, since it crashes silently and at different times…

My traces often stop after this line though:

trace( "Before setupApplication" ); Parse.service.setupApplication( parseAppId, parseClientKey, false );

  1. sep. 2015 kl. 00.37 skrev Michael notifications@github.com:

Hi, I've added that option in for you now, you'll have to setup your application as follows:

Parse.service.setupApplication( PARSE_APP_ID, PARSE_CLIENT_ID, false ); Parse.service.register( false ); — Reply to this email directly or view it on GitHub https://github.com/distriqt/ANE-Parse/issues/9#issuecomment-138387393.

marchbold commented 9 years ago

Does this occur when launching the app from closed or from the background?

simengjermundsen commented 9 years ago

From closed.

I guess it happens when it is supposed to handle a push notification instantly after initializing something. When the app is opened from background it is ready already.

  1. sep. 2015 kl. 11.40 skrev Michael notifications@github.com:

Does this occur when launching the app from closed or from the background?

— Reply to this email directly or view it on GitHub https://github.com/distriqt/ANE-Parse/issues/9#issuecomment-138856986.

marchbold commented 9 years ago

Found an issue with the parse analytics, try this update and let me know how it goes.

simengjermundsen commented 9 years ago

Working! :)

Thanks a lot.

  1. sep. 2015 kl. 04.28 skrev Michael notifications@github.com:

Found an issue with the parse analytics, try this update and let me know how it goes.

— Reply to this email directly or view it on GitHub https://github.com/distriqt/ANE-Parse/issues/9#issuecomment-139098270.