I am programming my app in corona sdks and am attempting to implement IAP into the app. I am using the sample code from http://coronalabs.com/blog/2013/09/03/tutorial-understanding-in-app-purchases/
What I don't get is how:
local function removeAds( event )
if event.phase == "began" then
event.target:setFillColor(224)
elseif event.phase == "ended" then
event.target:setFillColor(255)
if system.getInfo("targetAppStore") == "amazon" or system.getInfo("targetAppStore") == "google" then
store.purchase( "com.acme.superrunner.upgrade" )
else
store.purchase( { "com.acme.superrunner.upgrade" } )
end
end
return true
end
local buyBtn = display.newImageRect("images/buy_button.png", 614, 65)
group:insert( buyBtn )
buyBtn.x = display.contentCenterX - 465
buyBtn.y = 430
buyBtn:addEventListener( "touch", removeAds )
com.acme.superrunner.upgrade is never mention in the main.lua or utilities.lua files. Am I missing something, how does store.purchase( { "com.acme.superrunner.upgrade" } ) equate to something actually being unlocked in game. Thanks so much for any help! Is there another IAP file I need or something?
com.acme.superrunnerupgrade represents the ID of the store item for which you want the purchase to get initiated. This is usually configured in the Store's (Google play, Apple, Amazon) configuration.
After you configure your item / reward in the store, initiating a purchase to that item would take your user to the respective store item and carry out the payment process.
If the payment is completed, iTunes on the phone will get your app/game active and the callback function will be called.
In App Purchase for IOS are setup using iTunes connect. You can read about the process on the folliwing link: https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnectInAppPurchase_Guide/Chapters/Introduction.html
Related
I have implemented AppOpenAds from Admob, they work as intended...To a point.
Unfortunately, when the viewer is watching a 'rewarded' video (ie to get coins in-game) after it finishes, it then shows an AppOpenAd, as it obviously thinks the user has left the app (when they have just watched a video instead). So they are getting a double-whammy ad!
Is there any way I can stop this?
It's using this;
private void OnAppStateChanged(AppState state)
{
// Display the app open ad when the app is foregrounded.
UnityEngine.Debug.Log("App State is " + state);
if (state == AppState.Foreground)
{
AppOpenAdManager.Instance.ShowAdIfAvailable();
}
}
Edit - just to clarify - Rewarded ads work, they just then show an AppOpenAd when the rewarded ad finishes due to it thinking I was outside of the app.
How can I set local notifications with out forcing user to open app.
I need my app set a local notification for sunrise and sunset, but I don't want to ask people open app.
I know I can have up to 64 notifications via scheduleLocalNotification, but I need to set it for a year so I should be able to run app in background and set alarms for future sunrises and sunsets in background.
The simple answer is you can't. Your app can't run whenever it wants in the background; it can't schedule a timer to wake itself up to post more notifications when they are due.
The only way you could come close to something like this is by having a server which send a background push notification to your app as a wake-up call when a new batch of 64 notifications are coming close to needed to be posted.
However this would be relying on the fact the user doesn't terminate your app. If the user does then you'd have to send a non-background push notification to the user and hope they click on it to launch your app.
Android Awareness API has recently announced new features that provide a simple solution for your use-case (that avoids you having to explicitly manage location request or computing sunrise times). The way to achieve what you're trying to do is to create and register a TimeFence specified relative to sunrise/sunset.
For example:
// Create TimeFence
AwarenessFence sunriseFence =
TimeFence.aroundTimeInstant(TimeFence.TIME_INSTANT_SUNRISE,
0, 5 * ONE_MINUTE_MILLIS);
// Register fence with Awareness.
Awareness.FenceApi.updateFences(
mGoogleApiClient,
new FenceUpdateRequest.Builder()
.addFence("fenceKey", sunriseFence, myPendingIntent)
.build())
.setResultCallback(new ResultCallback<Status>() {
#Override
public void onResult(#NonNull Status status) {
if (status.isSuccess()) {
Log.i(TAG, "Fence was successfully registered.");
} else {
Log.e(TAG, "Fence could not be registered: " + status);
}
}
});
You will get callbacks when the fence evaluates to TRUE at sunrise, and when it evaluates back to FALSE at 5-min after sunrise.
Please check Fence API code snippets docs for how to add your custom app logic.
In my application i used in-app purchase.purchase and restore option doing well on my device.once in-app purchase or restore finished i set to remove lock image.but touch action not be called.in transaction callback function
if event.transaction.state == "purchased" then
db:exec("UPDATE inapproom SET product=1 WHERE id=1")
native.setActivityIndicator( false );
db:close()
store.finishTransaction( event.transaction )
sqlite3=nil;
lock1.alpha=0;
lock2.alpha=0;
lock3.alpha=0;
lock4.alpha=0;
lock5.alpha=0;
lock6.alpha=0;
but touch action not calling.when i move to other page and return back it work properly.
I just got started with Corona yesterday and love what I have seen thus far. I have run into a few issues with which I would like some help
It looks like a Corona app is set up to shut down as soon as the Home button on the phone is clicked. I have come across hints that this can be chanaged from build.settings but nothing more specific. What needs to be specified there?#
I imagine there are pause and resume events associated with when the app gets back/fore grounded?
I'd much appreciate any help with this
For iOS devices, add these in build.setting.
iphone =
{
plist =
{
UIApplicationExitsOnSuspend = false
}
}
Android will automatically suspend when home button is pressed.
See here.
For application suspend/resume handling, you can try:
function onSystemEvent( event )
if ( event.type == "applicationSuspend" ) then
--do stuff
elseif ( event.type == "applicationResume" ) then
--do stuff
end
end
Runtime:addEventListener( "system", onSystemEvent )
See here.
How to detect idle time in Corona? How to detect there is no user interaction or event with the device in a particular interval of time?The application what I am developing is based on user events.If the user doesn't provide any event for few minutes,the screen must be reloaded?Any idea about this with a sample code will be helpful.
Set up some counter which will count the idle time (maybe every second)...
When user touch the screen this timer will be set back to 0 - so when this counter reach some value (for example 60) then reload you page...
This is counter:
local idletime = 0
local function countidle()
idletime = idletime + 1
if idletime == 60 then
-- Code for restart
end
end
timer.performWithDelay(1000, countidle, 0)
Then do some function which will reset idletime value on touch...
Hope it helps ;)
You need a screen tap listener:
local function onScreenTap( event )
idletime =0
end
Runtime:addEventListener( "tap", onScreenTap )