Skip to content

Adds ParseAudience #372

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

Merged
merged 8 commits into from
Nov 10, 2017
Merged

Conversation

montymxb
Copy link
Contributor

@montymxb montymxb commented Nov 9, 2017

Adds support for interacting with the _Audience class in parse-server. This provides a means of sending pushes using queries while also maintaining tracking on the last sent date and total sends.

This also adjusts ParseQuery::_setConditions, which is used internally for decoding queries in ParsePushStatus objects. This is to fix a few observed issues with the decoding process and to support decoding all conditions besides just where, such as limit, skip, order, etc.

An example of using ParseAudience could be:

$query = ParseInstallation::getQuery();
$query->equalTo("deviceType", "ios");

// create & save your audience
$audience = ParseAudience::createAudience(
    'MyiOSAudience',
    $query
);
$audience->save(true);

// send a push using the query in this audience and it's id
// The 'audience_id' is what allows parse to update 'lastUsed' and 'timesUsed'
// You could use any audience_id with any query and it will still update that audience
ParsePush::send([
    'data'          => [
        'alert' => 'hello ios users!'
    ],
    'where'         => $audience->getQuery(),
    'audience_id'   => $audience->getObjectId()
], true);

// fetch changes to this audience
$audience->fetch(true);

// get last & times used for tracking
$timesUsed = $audience->getTimesUsed();
$lastUsed = $audience->getLastUsed();

@montymxb montymxb added this to the 1.4.0 milestone Nov 9, 2017
@codecov
Copy link

codecov bot commented Nov 9, 2017

Codecov Report

Merging #372 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #372      +/-   ##
==========================================
+ Coverage   98.98%   98.99%   +0.01%     
==========================================
  Files          37       38       +1     
  Lines        3451     3498      +47     
==========================================
+ Hits         3416     3463      +47     
  Misses         35       35
Impacted Files Coverage Δ
src/Parse/ParseClient.php 99.28% <100%> (ø) ⬆️
src/Parse/ParsePushStatus.php 100% <100%> (ø) ⬆️
src/Parse/ParseAudience.php 100% <100%> (ø)
src/Parse/ParseQuery.php 99.42% <100%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f72cc45...af148fe. Read the comment docs.

@montymxb montymxb merged commit 2b8ea3f into parse-community:master Nov 10, 2017
@montymxb montymxb deleted the push-audiences branch November 10, 2017 21:08
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.

1 participant