arleyandrada / PushClient

FREE and Open Source - Titanium PushClient Module
Other
44 stars 17 forks source link

Requires set remote-notification UIBackgroundModes in tiapp.xml #121

Closed sulthankareem closed 8 years ago

sulthankareem commented 8 years ago

Hi Sir,

Your module is working fine. Now i implemented this on ios. But it is not working as i needed. The problem is that when the application is running in backround , it will not execute a function that i decalerd in app.js file. So my question is what is the code that i have to put in ti.xml for application running in backround?

sulthankareem commented 8 years ago

My actual need is that, when i click on the push notification, the application will redirect to one specific page. For that I hav written a function called openOfferListing(). But when the application running in background it will not execute that function. My code is below

else if (event.mode == PushClient.MODE_BACKGROUND) { openOfferListing(); PushClient.endBackgroundHandler(event.data.handlerId); } I have to execute the function openOfferListing();

What is the code that i hav to add in ti.xml?

arleyandrada commented 8 years ago

Hi,

There is some differences from "background", "not running" and "killed" states.

I've described the behaviors related to each app state previously: https://github.com/arleyandrada/PushClient/issues/120#issuecomment-186189973

Specifically on the use of "background push notifications" on iOS, you must follow the following instructions:

1 - Enable iOS background push notification, setting the UIBackgroundModes in tiapp.xml

    <ios>
        <plist>
            <dict>
                .....
                <key>UIBackgroundModes</key>
                <array>
                    <string>remote-notification</string>
                </array>
                .....

2 - Send messages containing the "content-available" attribute

{
"content-available" : 1,
"alert" : "Hello world!"
}

That's all!

Regards,

Arley

sulthankareem commented 8 years ago

Thanks. Let me check

arleyandrada commented 8 years ago

Hi,

There is a IMPORTANT tip related to this problem:

You need to continue to call the registerPush method at every app startup (at app.js or index.js), regardless the device is already registered.

Regards,

Arley

sulthankareem commented 8 years ago

working fine. thanks