Data get's lost when setting "content_available" or "mdm" #94

Closed
dup2 opened this Issue Jan 14, 2013 · 1 comment

Comments

Projects
None yet
1 participant
Contributor

dup2 commented Jan 14, 2013

When setting additional data in a APN for the device using the data attribute setter and setting the content_available flag afterwards for a newsstand application, the data gets lost.

1.9.3p194 :016 > n = Rapns::Apns::Notification.new :data=> {:foo => :bar}
=> #<Rapns::Apns::Notification id:nil ....
1.9.3p194 :017 > n.as_json
 => {"aps"=>{"sound"=>"default"}, "foo"=>"bar"}
1.9.3p194 :018 > n.content_available = true
 => true 
1.9.3p194 :019 > n.as_json
=> {"aps"=>{"sound"=>"default", "content-available"=>1}}

The cause of this issue is the method content_available= at Rapns::Apns::Notification line 50ff, the internal data gets written and not appended. The same happens when using mdm=.

The other way round has the same problem, when first setting the content_available flag and the data later on, the flag is lost:

1.9.3p194 :030 >   n = Rapns::Apns::Notification.new 
 => #<Rapns::Apns::Notification id:nil ...
1.9.3p194 :031 > n.content_available = true
 => true 
1.9.3p194 :032 > n.as_json
 => {"aps"=>{"sound"=>"default", "content-available"=>1}} 
1.9.3p194 :033 > n.data = {:foo => :bar}
 => {:foo=>:bar} 
1.9.3p194 :034 > n.as_json
 => {"aps"=>{"sound"=>"default"}, "foo"=>"bar"} 
Contributor

dup2 commented Jan 14, 2013

Pull Request #95 should fix this.

ileitch added a commit that referenced this issue Jan 16, 2013

Merge pull request #95 from ncoders/master
content_available and data setter fixes (issue #94)

@dup2 dup2 closed this Jan 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment