Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed to send extra parameters and added ability to send hidden messages. #266

Merged
merged 5 commits into from Jul 4, 2017

Conversation

bitsal
Copy link
Contributor

@bitsal bitsal commented Jun 5, 2017

Hidden messages were verified on Android. On iOS it should work out-of-the-box using empty contents and content_available=1.

It should fix #115

@controversialUser
Copy link

can you show us an example how to use it for android please ?

@bitsal
Copy link
Contributor Author

bitsal commented Jun 11, 2017

The same like for iOS
e.g.

OneSignal.postNotification({ en: 'Message' }, { prop1: '1', prop2: 5 }, playerId, { priority: 10 });

@controversialUser
Copy link

well i made all the changes you made in 4 files , and than executed the code you gave me:

OneSignal.postNotification({ en: 'Message' }, { prop1: '1', prop2: 5 }, playerId, { priority: 10 });

but still not working for android ... have you tested this ?

@bitsal
Copy link
Contributor Author

bitsal commented Jun 12, 2017

@controversialUser of course, it was required for our project app. Our team tested it a lot during the last week.

What exactly doesn't work for you? If you mean new hidden parameter. It will work only after you add it to your AndroidManifest.xml how it is described here.
E.g. our version

<application
      android:name=".MainApplication"
      android:theme="@style/AppTheme"
...>

      <activity ...>
          ...
      </activity>

      <service
        android:name="com.geektime.rnonesignalandroid.NotificationNotDisplayingExtender"
        android:exported="false">
        <intent-filter>
          <action android:name="com.onesignal.NotificationExtender" />
        </intent-filter>
      </service>
    </application>

@controversialUser
Copy link

well when my app is open in android and i get a notification , an alert comes to the screen ... i dont want that alert , in ios is ok , but what can i do in android to prevent that alert ... have your team found a solution ?

@bitsal
Copy link
Contributor Author

bitsal commented Jun 12, 2017

@controversialUser I guess you mean OneSignal.inFocusDisplaying(2); - it works only for Android.
All options: 0 -> None, 1 -> InAppAlert, 2 -> Notification.

It is not related to new changes.

@jamieparkinson
Copy link

@controversialUser to be clear; are you adding hidden: true to the final argument of OneSignal.postNotification? To be explicit:

OneSignal.postNotification(
    { }, // No content
    { foo: 'bar' }, // data
    playerId, // recipient
    // other params, as introduced in this PR
    {
        priority: 10,
        android_visibility: -1,
        hidden: true
    }
)

@avishayil looking forward to this getting merged! 🙂

@controversialUser
Copy link

@jamieparkinson "hidden: true" helped me , thanks a lot ... @bitsal you are a hero bro , thanks for all :)

@Ouadie
Copy link

Ouadie commented Jun 13, 2017

This PR do the job, could you please merge it!

@bitsal
Copy link
Contributor Author

bitsal commented Jun 22, 2017

Is anybody going to review it? I wonder why it is in review status so long. 9 days from the last comment

@loiclouvet
Copy link

Good job, waiting for it to be merged ! 👍

@jkasten2
Copy link
Member

@avishayil This looks good to me. Could you merge this?

@maxs15
Copy link
Contributor

maxs15 commented Jun 28, 2017

Tested on my side as well, working well good job 👍
Android is now working like IOS, my push with content_available=1is silent without specifying the hidden parameter.

@avishayil avishayil merged commit 52a44f0 into OneSignal:master Jul 4, 2017
@floydus
Copy link

floydus commented Sep 22, 2017

Would be nice to have a complete example including path of any Java classes and AndroidManifest.
I'm having the same issue, works perfectly after editing AppDelegate in iOS, but for Android, no f... luck.

@bitsal
Copy link
Contributor Author

bitsal commented Sep 22, 2017

@floydus could you describe your issue in detail (I will try to help)? I've described all changes above what we did to make it work (AndroidManifest is also there).
BTW, I didn't mention any changes that are in origin react-native-onesignal documentation. Everybody can read them there. No extra changes are required for AppDelegate.

@illright
Copy link

Does this pull request affect only P2P notifications? I'm looking for a way to silently process notifications that are sent programmatically through an API. Is this what I'm looking for?

@bitsal
Copy link
Contributor Author

bitsal commented Oct 23, 2017

From the server, you could send all parameters before my changes I guess.

@isaaclem
Copy link

@bitsal: Thank you very much on your helps. However I'm wondering if it's gonna support if the app has been killed? I'm testing on Android Emulator with below curl

curl --include \
     --request POST \
     --header "Content-Type: application/json; charset=utf-8" \
     --data-binary "{\"app_id\": \"xxx\",
\"contents\": {},
\"content_available\": 1,
\"include_player_ids\": [\"xxxx\"]}" \
https://onesignal.com/api/v1\/notifications

When the app is in background or foreground, it's working fine, however if the app has been killed, event doesn't seems to be triggered. Is this a known issue?

@bitsal
Copy link
Contributor Author

bitsal commented Oct 24, 2018

@isaaclem It didn't work for me either with that version of this library for a case when app is closed. Please check official documentation about whether it is possible just to be sure it is possible or an issue on SDK/library side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How do I send silent notifications on Android?