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 3 of 4 1 2 3 4
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#51

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

After store.init() and store.loadProducts()

 

I'm using:

store.restore()

but never reach store init function as it looks

    
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("Success", "Thank you for the purchase", {"OK"})
                removeLocking()
                
                
        elseif e.transaction.state == "restored" then   
            native.showAlert("Success", "Your product is restored!", {"OK"})

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

store.loadProducts()


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



[TOPIC: post.html]
#52

Scott Harrison

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

  • 1,785 posts
  • Enterprise

2017-01-08 18:32:18.779683 App[305:130278] restore
2017-01-08 18:32:19.421180 App[305:130278] init
2017-01-08 18:32:19.421403 App[305:130278] ------
2017-01-08 18:32:19.424043 App[305:130278] {"state":"restored","transaction":[{"productIdentifier":"thePack3","date":"00:32 2017/Jan/9","originalReceipt":"{\"status\":0, \"environment\":\"Sandbox\", \n\"receipt\":{\"receipt_type\":\"ProductionSandbox\", \"adam_id\":0, \"app_item_id\":0, \"bundle_id\":\"com.scotthinc.com\", \"application_version\":\"1\", \"download_id\":0, \"version_external_identifier\":0, \"receipt_creation_date\":\"2017-01-09 00:32:19 Etc/GMT\", \"receipt_creation_date_ms\":\"1483921939000\", \"receipt_creation_date_pst\":\"2017-01-08 16:32:19 America/Los_Angeles\", \"request_date\":\"2017-01-09 00:32:19 Etc/GMT\", \"request_date_ms\":\"1483921939368\", \"request_date_pst\":\"2017-01-08 16:32:19 America/Los_Angeles\", \"original_purchase_date\":\"2013-08-01 07:00:00 Etc/GMT\", \"original_purchase_date_ms\":\"1375340400000\", \"original_purchase_date_pst\":\"2013-08-01 00:00:00 America/Los_Angeles\", \"original_application_version\":\"1.0\", \n\"in_app\":[\n{\"quantity\":\"1\", \"product_id\":\"thePack3\", \"transaction_id\":\"1000000244365152\", \"original_transaction_id\":\"1000000244365152\", \"purchase_date\":\"2016-10-21 06:08:37 Etc/GMT\", \"purchase_date_ms\":\"1477030117000\", \"purchase_date_pst\":\"2016-10-20 23:08:37 America/Los_Angeles\", \"original_purchase_date\":\"2016-10-21 06:08:37 Etc/GMT\", \"original_purchase_date_ms\":\"1477030117000\", \"original_purchase_date_pst\":\"2016-10-20 23:08:37 America/Los_Angeles\", \"is_trial_period\":\"false\"}, \n{\"quantity\":\"1\", \"product_id\":\"com.anscamobile.NewExampleInAppPurchase.SubscriptionTier2\", \"transaction_id\":\"1000000244700036\", \"original_transaction_id\":\"1000000244700036\", \"purchase_date\":\"2016-10-23 05:39:59 Etc/GMT\", \"purchase_date_ms\":\"1477201199000\", \"purchase_date_pst\":\"2016-10-22 22:39:59 America/Los_Angeles\", \"original_purchase_date\":\"2016-10-23 05:39:59 Etc/GMT\", \"original_purchase_date_ms\":\"1477201199000\", \"original_purchase_date_pst\":\"2016-10-22 22:39:59 America/Los_Angeles\", \"is_trial_period\":\"false\"}, \n{\"quantity\":\"1\", \"product_id\":\"com.anscamobile.NewExampleInAppPurchase.SubscriptionTier2\", \"transaction_id\":\"1000000244966896\", \"original_transaction_id\":\"1000000244966896\", \"purchase_date\":\"2016-10-24 17:27:16 Etc/GMT\", \"purchase_date_ms\":\"1477330036000\", \"purchase_date_pst\":\"2016-10-24 10:27:16 America/Los_Angeles\", \"original_purchase_date\":\"2016-10-24 17:27:16 Etc/GMT\", \"original_purchase_date_ms\":\"1477330036000\", \"original_purchase_date_pst\":\"2016-10-24 10:27:16 America/Los_Angeles\", \"is_trial_period\":\"false\"}, \n{\"quantity\":\"1\", \"product_id\":\"com.anscamobile.NewExampleInAppPurchase.SubscriptionTier2\", \"transaction_id\":\"1000000244967360\", \"original_transaction_id\":\"1000000244967360\", \"purchase_date\":\"2016-10-24 17:28:18 Etc/GMT\", \"purchase_date_ms\":\"1477330098000\", \"purchase_date_pst\":\"2016-10-24 10:28:18 America/Los_Angeles\", \"original_purchase_date\":\"2016-10-24 17:28:18 Etc/GMT\", \"original_purchase_date_ms\":\"1477330098000\", \"original_purchase_date_pst\":\"2016-10-24 10:28:18 America/Los_Angeles\", \"is_trial_period\":\"false\"}, \n{\"quantity\":\"1\", \"product_id\":\"com.anscamobile.NewExampleInAppPurchase.SubscriptionTier2\", \"transaction_id\":\"1000000244967439\", \"original_transaction_id\":\"1000000244967439\", \"purchase_date\":\"2016-10-24 17:29:32 Etc/GMT\", \"purchase_date_ms\":\"1477330172000\", \"purchase_date_pst\":\"2016-10-24 10:29:32 America/Los_Angeles\", \"original_purchase_date\":\"2016-10-24 17:29:32 Etc/GMT\", \"original_purchase_date_ms\":\"1477330172000\", \"original_purchase_date_pst\":\"2016-10-24 10:29:32 America/Los_Angeles\", \"is_trial_period\":\"false\"}, \n{\"quantity\":\"1\", \"product_id\":\"com.anscamobile.NewExampleInAppPurchase.NonConsumableTier1\", \"transaction_id\":\"1000000244699775\", \"original_transaction_id\":\"1000000244699775\", \"purchase_date\":\"2016-10-23 05:26:23 Etc/GMT\", \"purchase_date_ms\":\"1477200383000\", \"purchase_date_pst\":\"2016-10-22 22:26:23 America/Los_Angeles\", \"original_purchase_date\":\"2016-10-23 05:26:23 Etc/GMT\", \"original_purchase_date_ms\":\"1477200383000\", \"original_purchase_date_pst\":\"2016-10-22 22:26:23 America/Los_Angeles\", \"is_trial_period\":\"false\"}]}}","packageName":"com.scotthinc.com"}],"name":"storeTransaction"}
2017-01-08 18:32:19.425202 App[305:130278] ------

restore seems to happen for me

modded code before to this

store.init(function(e)
    print( "init")
    print( "------" )
    print(json.encode(e) )
    print( "------" )
    if e.transaction.state == "purchased" then
        print( "restore")
        store.restore()
    end
end)


[TOPIC: post.html]
#53

Scott Harrison

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

  • 1,785 posts
  • Enterprise

that may be my fault

 

e.state == "restored"



[TOPIC: post.html]
#54

Scott Harrison

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

  • 1,785 posts
  • Enterprise

will fix it



[TOPIC: post.html]
#55

Scott Harrison

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

  • 1,785 posts
  • Enterprise

pushed out and update (will take up to an hour to) that should fix 

 

e.transaction.state == "restored"



[TOPIC: post.html]
#56

Scott Harrison

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

  • 1,785 posts
  • Enterprise

please note publisher id has changed from "com.scottrules44" to "tech.scotth"

https://forums.coronalabs.com/topic/67229-buildsettings-publisher-id-change-soon-for-comscottrules44/?p=348072



[TOPIC: post.html]
#57

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

Scott, when I change to the new publisherID I get this when trying to upload to appstore. 

Package Summary:
 
1 package(s) were not uploaded because they had problems:
	/var/folders/90/ws67dmw52y7gw4xksq1pgj_h0000gn/T/0B240973-D80B-4712-8B25-04C0EF98DE4A/1131252020.itmsp - Error Messages:
		ERROR ITMS-90087: "Unsupported Architectures. The executable for Deep Ocean Aquarium.app/Frameworks/Corona_plugin_storeKit.framework contains unsupported architectures '[x86_64]'."
		ERROR ITMS-90635: "Invalid Mach-O Format. The Mach-O in bundle "Deep Ocean Aquarium.app/Frameworks/Corona_plugin_storeKit.framework" isn’t consistent with the Mach-O in the main bundle. The main bundle Mach-O contains arm64(bitcode and machine code), while the nested bundle Mach-O contains X86_64ALL(machine code). Verify that all of the targets for a platform have a consistent value for the ENABLE_BITCODE build setting."
		ERROR ITMS-90209: "Invalid Segment Alignment. The app binary at 'Deep Ocean Aquarium.app/Frameworks/Corona_plugin_storeKit.framework/Corona_plugin_storeKit' does not have proper segment alignment. Try rebuilding the app with the latest Xcode version."
		ERROR ITMS-90125: "The binary is invalid. The encryption info in the LC_ENCRYPTION_INFO load command is either missing or invalid, or the binary is already encrypted. This binary does not seem to have been built with Apple's linker."



[TOPIC: post.html]
#58

Scott Harrison

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

  • 1,785 posts
  • Enterprise

Looking into it



[TOPIC: post.html]
#59

Scott Harrison

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

  • 1,785 posts
  • Enterprise

should be fixed(please try again in an hour)



[TOPIC: post.html]
#60

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

Now it looks like everything except restore() works.

 

Can't get store.restore() to work. It never returns to the init callback and I have to kill the app and restart inorder to use the app again.



[TOPIC: post.html]
#61

Scott Harrison

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

  • 1,785 posts
  • Enterprise

Now it looks like everything except restore() works.

Can't get store.restore() to work. It never returns to the init callback and I have to kill the app and restart inorder to use the app again.


Can you describe the issue better? Is it crashing or freezing after restore? When did you build?

[TOPIC: post.html]
#62

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

When restore() is called the app freezes. I can just press Menu to get back to Home. Navigation stops. I've don some building the last couple of hours.



[TOPIC: post.html]
#63

Scott Harrison

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

  • 1,785 posts
  • Enterprise

ok looking into it



[TOPIC: post.html]
#64

Scott Harrison

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

  • 1,785 posts
  • Enterprise

It seems to be working for me, can i get some logs?



[TOPIC: post.html]
#65

Scott Harrison

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

  • 1,785 posts
  • Enterprise

I just pushed update used array of tables instead of a new event for every item to restore so e.transaction.state == "restored"



[TOPIC: post.html]
#66

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

Thanks. Now it works! :)



[TOPIC: post.html]
#67

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

There is still an odd thing going on with the audio. In the app I have two scenes. One main menu scene and one video scene.

 

In the menu there are 4 buttons. When you click on a button it goes to the video scene and load/start an audiostream and a videofile (with no sound). One clip is free and the other needs to be unlocked.

 

Problem is this.

1. Click on button one with the free clip and watch the video (goes to videoscene)

2. Press Menu (returns to the menu scene and stops the audio and video) 

3. Make the purchase and unlock the videos

4. Click on any button to start free or unlocked clip. The video starts but audio is muted. 

 

If one kill the app and restart it everything works. If one make a restore (If unlock already purchased) everything works. If one make the purchase without playing the free clip first everything works. So I thought it may be something with playing both a video and an audiostream at the same time. But the problem only occurs after the purchase so maybe there is something in storeKit that mutes the audio? It feels like something is muting the audio "behind the scene". Even if I reset the volume, stop the audio, dispose it, reload and rewind, reserve channels, remove video scene and reload scene nothing works. But as soon as I restart the app, it works again and it only happens after a purchase. It's really odd. 



[TOPIC: post.html]
#68

Scott Harrison

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

  • 1,785 posts
  • Enterprise

Can you make a demo project demonstrating this issue? For the record, my plugin does not do anything with the audio.

[TOPIC: post.html]
#69

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

Hi again. 

 

I uploaded a new version yesterday but it's still the same problem when purchasing. But now restore works. I first build the app an tested through Testfligt and everything worked. Both purchase and restore. Then I activated the same build for the store and now it's for sale but you can't make any purchase. But now you can restore a purchase.

 

When trying to do a purchase I get all alerts from Appstore as normal. "Please confirm you want to purchase...", "You have already purchased..." etc. 

 

The code is from your post:

----=======================================---
-- Configure IAP
----=======================================---

    
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("Success", "Thank you for the purchase", {"OK"})
            removeLocking()
                   
                
        elseif e.transaction.state == "restored" then   
            --native.showAlert("Success", "Your product is restored!", {"OK"})

            removeLocking() 
            
        elseif e.transaction.state == "failed" then    
            native.setActivityIndicator( false )  
            --native.showAlert("Failed", "Your purchase failed. Please, try again.", {"OK"})
            waitForPurchase = false  
            
        else
            native.setActivityIndicator( false )
            waitForPurchase = false
	end
end)

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

local Products = { "com.filmicart.deepocean.unlockvideos" }
local ProductToPurchase = "com.filmicart.deepocean.unlockvideos" 

timer.performWithDelay( 1000, function ( )
	store.loadProducts( Products, function ( e )
        print( "loadProducts")
        print( "------" )
        print(json.encode(e) )   
        print( "------" )
        
        
        local p = e.products[1]
        
        if p ~= nil then
            print(p.title)
            print(p.localizedPrice)
        end
        
    end )
    
        
        
end)

Is there another status I need to fetch. I don't know if Apple handles Testflights different from a released except that I'm using a Sandbox tester for Testflight and my real user for the released version.

 

The calling code:

                        native.setActivityIndicator( true )

                        store.purchase(ProductToPurchase)

 Any idea?



[TOPIC: post.html]
#70

Scott Harrison

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

  • 1,785 posts
  • Enterprise

I am working on a fix, I have to try to guess since I don't have any Apple TV apps to test. That being said I think I know what the issue is. Working on a fix

[TOPIC: post.html]
#71

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

Thanks. If you have space on your ATV you can download the app, if it helps you. It's 620MB. ;)



[TOPIC: post.html]
#72

Scott Harrison

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

  • 1,785 posts
  • Enterprise

Can you post or email me the link I might take a lot at it

[TOPIC: post.html]
#73

Scott Harrison

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

  • 1,785 posts
  • Enterprise

Pushed out update please try again in hour



[TOPIC: post.html]
#74

mfr

[GLOBAL: userInfoPane.html]
mfr
  • Enthusiast

  • 56 posts
  • Corona SDK

Scott, there is still the same problem. Purchase never finish but restore works. Maybe there is a problem with transaction sin the que that are unfinished? Both me and me client have tested without sucess. When trying from Testflight (same build as the released) everything works. So only way to test right now is to release a new version. It looks like Apple completes the purchase and charge the user but StoreKit doesn't seems to recieve e.transaction == "purchased"

 

Right now I will try to rebuild the app in Swift but I would be really nice to use your plugin and Corona instead.



[TOPIC: post.html]
#75

Scott Harrison

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

  • 1,785 posts
  • Enterprise

Just curious does cancel work at all?


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