Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

StoreKit not working on tvOS
Started by mfr Dec 16 2016 07:10 AM

82 replies to this topic
[TOPIC CONTROLS]
Page 2 of 4 1 2 3 4
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

Hi Rob,

 

I have tried to set the volume back to 100% but maybe I just did that with the actual channel. Will try your suggestion. Thanks.

 

Magnus



[TOPIC: post.html]
#27

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

Are you getting any output in your logs?

[TOPIC: post.html]
#28

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

Did robs advise fix the problem @mfr? Just wondering.

[TOPIC: post.html]
#29

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

No, it didn't work. I can see that the volume is set to the right level but no sound. Right now I have the code below. 

audio.setVolume( 0.75, { channel=1 } ) 
audio.setVolume( 1 )


[TOPIC: post.html]
#30

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

I have finally managed to upload the app to Appstore but when I try to buy StoreKit doesn't fire  "purchased" state. It works when I copy to device and use a Sandbox tester but not from the downloaded version from App store. The transaction is never ended and no errors seems to be triggered so nothing happens. 



[TOPIC: post.html]
#31

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

I think I fixed problem(just pushed update so wait 1 hour) with the store kit plugin not working out side of sandbox, I don't really have any apps out side of sandbox to test on but made sure all event's were loaded on main thread which is my guess on why load products works but the other functions don't. Let me know if the update does not fix it but I have some confidence. As for that audio bug, I just got home today, will try testing tomorrow after noon. I have guess on what is causing the audio to stop but will put it to the test tomorrow.



[TOPIC: post.html]
#32

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

Still the same problem. It works in sandbox mode and I haven't change anything in the code. See attached store.init function

----------------------
-- Init Store
----------------------

store.init(function(e)
    print( "init") 
    print( "------" )
    print(json.prettify(e) )
    print( "------" )
    

    --print("error? ", e.isError)
    if e.isError == true or e.isError == nil or e.transaction.state == nil then
        if e.isError then
            print(e.errorType, e.errorString)
        end
        waitForPurchase = false    
        native.setActivityIndicator( false )
        
    else
        --print("No error. STATE:  ", e.transaction.state)
        if e.transaction.state == "purchased"  then
            native.setActivityIndicator( false )
            native.showAlert("Success", "Thank you for the purchase", {"OK"}, function(event)

                    -- Spara kvitto      
                    m.iApUpgrade = true;
                    m.receipt = e.transaction.originalReceipt
                
                    
                    
                    --print("will remove locking")
                    removeLocking()

                end )

        elseif e.transaction.state == "restored" then   
            --native.showAlert("Success", "Your product is restored!", {"OK"})

            -- Spara kvitto      
            m.iApUpgrade = true;
            m.receipt = e.transaction.originalReceipt

            removeLocking()

        else

            waitForPurchase = false    
            native.setActivityIndicator( false )

            if e.transaction.state == "failed" then    
                native.showAlert("Failed", "Your purchase failed. Please, try again.", {"OK"})
                native.setActivityIndicator( false )

            elseif e.transaction.state == "cancelled" then    
                --native.showAlert("Cancelled", "Your transaction was cancelled. Please, try again.", {"OK"}, function(event)
                     --waitForPurchase = false
                native.setActivityIndicator( false )
                --end )   
            end
        end
    end
    
end)


[TOPIC: post.html]
#33

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

pushed update an hour ago



[TOPIC: post.html]
#34

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

I still have the same problem. StoreKit doesn't seem to recieve any transaction state or error after the purchase.

 

It looks like App Store register the transaction and take to money but the app never recieved the status and the user can't unlock the extra videos. 



[TOPIC: post.html]
#35

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

I still have the same problem. StoreKit doesn't seem to recieve any transaction state or error after the purchase.

 

It looks like App Store register the transaction and take to money but the app never recieved the status and the user can't unlock the extra videos. 

 

1. is this still happening in sandbox or app store

2.when did you build app

3.what version of Xcode and tvOs are you running

4. are you getting anything in your apple tv logs

PS: I pushed out an update an hour which made sure that the apple tv framework was properly build which may or may not help.

Thanks, Scott



[TOPIC: post.html]
#36

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

1. It works when I copy the app to the device and make a purchase with a sandbox user but when downloading the released version from on App Store.

2. Jan 6, 2017 at 3:11 PM

3. XCode: Version 8.2.1 (8C1002)

4. No, but will test again.

 

Corona Daily build: Version 2016.3012 (2016.12.29)



[TOPIC: post.html]
#37

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,544 posts
  • Enterprise

Before you run the app store version are you completely logging out of the app store and logging in with a non-sandboxed account?

 

Rob


  • Scott Harrison likes this

[TOPIC: post.html]
#38

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

Yes, i'm using a non-sandbox user for the appstore version.



[TOPIC: post.html]
#39

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

I'm making more tests and maybe there is something with .loadProducts. At startup I call store.init and then store.loadProducts as described in the docs.

 

When testing on device storeKit returns:

 

[Device] init
[Device] ------
[Device] {
[Device] ------

 

[Device] loadProducts
[Device] ------
[Device] {
[Device] ------
 
In sandbox e.invalidProducts = true
But the purchase still works in sandbox. When calling store.restore() nothing happens.
 
 
 
@scott, in the docs I noticed you have changed publisherID. Do I need to change that in my code? 


[TOPIC: post.html]
#40

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

 

 

@scott, in the docs I noticed you have changed publisherID. Do I need to change that in my code? 

Yes



[TOPIC: post.html]
#41

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,544 posts
  • Enterprise

You might want to consider delaying the loadProducts call. If .init() isn't done initing and you call loadProducts too soon, it won't be ready. Most networking type things are called asynchronous which means we start the process in the background and return to your app immediately so you app doesn't pause waiting on a slow network connection.

 

I can't speak for how much work Scott's plugin does during the init phase, but you can either load the products on a timer of a second or two. I doubt your users are going to be hitting the buy button within the first few seconds of the app starting. Or if the .init() call calls it's on call back function to say it's done initializing, then you could use that as your indicator that the system is ready to go and then call loadProducts() from that listener.  I would even wrap that call in a short timer (say 10ms) to make sure that listener function has time to exit before it gets called again by some other API call.

 

Rob



[TOPIC: post.html]
#42

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

@scott, when I change publisherID I get an error message when trying to build.

 

------------------

A device build error occurred on the server. 

 

Error: You are not subscribed to the following plugin:

 

Plugin: plugin.storeKit 

Publisher: tech.scotth

 

--------------

The plugin is activated and paid since dec 13, 2016.



[TOPIC: post.html]
#43

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

That's odd

[TOPIC: post.html]
#44

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

my bad, I was assuming changing the publisher id in metadata.json affect the marketplace hosting publisher id. I would continue to use the com.scottrules44 until everything is sorted out.



[TOPIC: post.html]
#45

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

Just tested in sand box, 

Used the following code(used timer because i am not good with joysticks

local store = require("plugin.storeKit")
local json = require("json")
store.init(function(e)
	print( "init") 
	print( "------" )
	print(json.encode(e) )
    print( "------" )
	if e.transaction.state == "purchased" then
		native.showAlert("storeKit", "the purchase worked", {"ok"})
	end
end)

local Products = {"com.anscamobile.NewExampleInAppPurchase.NonConsumableTier1", "com.anscamobile.NewExampleInAppPurchase.ConsumableTier1"}
local thePurchaseProduct = "com.anscamobile.NewExampleInAppPurchase.ConsumableTier1"

timer.performWithDelay( 1000, function ( )
	store.loadProducts( Products, function ( e )
        print( "loadProducts")
        print( "------" )
        print(json.encode(e) )
        print( "------" )
        timer.performWithDelay( 3000, function ( ... )
			store.purchase(thePurchaseProduct)
		end)
		native.showAlert("storeKit", "products loaded", {"ok"})
	end )
end)

Got the following out:(noted i cutted out unimportant things)

 [Device] loadProducts
Jan 08 02:01:07.269 [Device] ------
Jan 08 02:01:07.270 [Device] {"products":[{"title":"ConsumableTier1","productIdentifier":"com.anscamobile.NewExampleInAppPurchase.ConsumableTier1","localizedPrice":3.99,"price":3.99,"description":"cool ConsumableTier1"},{"title":"NonConsumableTier1","productIdentifier":"com.anscamobile.NewExampleInAppPurchase.NonConsumableTier1","localizedPrice":1.99,"price":1.99,"description":"cool NonConsumableTier1"}],"name":"productList","invalidProducts":[]}
                    [Device] ------
Jan 08 02:03:28.099 [Device] init
Jan 08 02:03:28.108 [Device] ------
Jan 08 02:03:28.108 [Device] {"transaction":{"state":"purchased","originalReceipt":"{\134"status\134":0, \134"environment\134":\134"Sandbox\134", \134n\134"receipt\134":{\134"receipt_type\134":\134"ProductionSandbox\134", \134"adam_id\134":0, \134"app_item_id\134":0, \134"bundle_id\134":\134"com.scotthinc.com\134", \134"application_version\134":\134"2017.01.081400\134", \134"download_id\134":0, \134"version_external_identifier\134":0, \134"receipt_creation_date\134":\134"2017-01-08 20:03:26 Etc/GMT\134", \134"receipt_creation_date_ms\134":\134"1483905806000\134", \134"receipt_creation_date_pst\134":\134"2017-01-08 12:03:26 America/Los_Angeles\134", \134"request_date\134":\134"2017-01-08 20:03:28 Etc/GMT\134", \134"request_date_ms\134":\134"1483905808471\134", \134"request_date_pst\134":\134"2017-01-08 12:03:28 America/Los_Angeles\134", \134"original_purchase_date\134":\134"2013-08-01 07:00:00 Etc/GMT\134", \134"original_purchase_date_ms\134":\134"1375340400000\134", \134"original_purchase_date_pst\134":\134"2013-08-01 00:00:00 America/Los_Angeles\134", \134"original_application_version\134":\134"1.0\134", \134n\134"in_app\134":[\134n{\134"quantity\134":\134"1\134", \134"product_id\134":\134"thePack3\134", \134"transaction_id\134":\134"1000000244365152\134", \134"original_transaction_id\134":\134

My tv is showing an alert that says "title" storeKit "the purchase worked" (with ok button), I just (jan/7 1:58) tested this using the latest every thing(stable build, Xcode, and tvOS os) also I am using the real account(just type my long apple password into the tv, fun ;)

 

I am going to test audio



[TOPIC: post.html]
#46

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

Testing with lasted stable build audio is continues play



[TOPIC: post.html]
#47

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

also test with daily builds CoronaSDK 2016.3012 

just added 

local someLoopingMusic = audio.loadStream( "sampleMusic.mp3" )
local someLoopingMusicChannel = audio.play( someLoopingMusic, { channel=1, loops=-1 } )

to the sample above. audio and events seem fine

 

proof:

 

https://www.dropbox.com/s/c8ooptdtedntb6n/Video%20Jan%2008%2C%202%2017%2049%20PM.mov?dl=0

 

Please make sure your products are loaded before you purchase.

From docs https://scotth.tech/plugin-storeKit :

Gotchas:
You must .loadProducts before restoring or buying 

Also make sure info is setup correctly in iTunes connect

 

Thanks

Scott



[TOPIC: post.html]
#48

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

I'm trying the following code

timer.performWithDelay( 1500, function ()
        store.loadProducts( Products, function ( e )
            print( "loadProducts")
            print( "------" )
            print(json.prettify(e) )
            print( "------" )

            --
            --native.showAlert("Store", "Products loaded", {"OK"})


            if e.invalidProducts then
                --native.showAlert("Error", "Didn't find any products", {"OK"})
                -- No products availble
          
                --ProductPrice = "$2.99"
            else
                native.showAlert("Store", "Products loaded", {"OK"})


                ProductPrice = e.products.localizedPrice or "$2.99"
                print(" price locale: "..e.products.localizedPrice)

                productsLoaded = true


            end


        end )
end)    
  
    

Still get the following out:

[Device] loadProducts
[Device] ------
[Device] {
[Device] ------


[TOPIC: post.html]
#49

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

hmm it looks like it's working now. I just changed

print(json.prettify(e) )

to

print(json.encode(e) )

then I recieved the product list.

 

But I can't get store.restore() to work. Right now I just re-use the purchase option when one want to restore. I will try to upload to appstore again. Thanks for your help so far.



[TOPIC: post.html]
#50

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,785 posts
  • Enterprise

can you show me how you are using restore?




[topic_controls]
Page 2 of 4 1 2 3 4
 
[/topic_controls]