Question

I am using phonegap 2.6.0 in, ios 7 sdk the device is 5.1 . I have implemented In-app purchase manager plugin

On the deviceready function i have tried call the requestData() function but its not firing as it should be

function onDeviceReady(){
    alert(window.plugins.inAppPurchaseManager); //-->This alerts as Object

    window.plugins.inAppPurchaseManager.onPurchased = function(transactionIdentifier, productId, transactionReceipt) {
        updatePurchaseTable(productId);
        window.location.reload();
        console.log('purchased: ' + productId);
    }

    window.plugins.inAppPurchaseManager.onRestored = function(transactionIdentifier, productId, transactionReceipt) {
        console.log('restored: ' + productId);
         /*See the developer guide for details of what to do with this */
    }

    window.plugins.inAppPurchaseManager.onFailed = function(errno, errtext) {
        alert('failed: ' + errtext);
    }
    window.plugins.inAppPurchaseManager.requestProductData("ProductId1", function(result) {
            alert(result.id);  //-->this doesn't happen
            console.log("productId: " + result.id + " title: " + result.title + " description: " + result.description + " price: " + result.price);
                  //window.plugins.inAppPurchaseManager.makePurchase(result.id, 1);
            }, function(id) {
            alert("Invalid product id: " + result.id);
            }
    );


}

my config.xml file

<?xml version="1.0" encoding="UTF-8"?>

<widget>
    <preference name="AllowInlineMediaPlayback" value="false" />
    <preference name="AutoHideSplashScreen" value="true" />
    <preference name="BackupWebStorage" value="cloud" />
    <preference name="DisallowOverscroll" value="false" />
    <preference name="EnableLocation" value="false" /><!-- DEPRECATED -->
    <preference name="EnableViewportScale" value="false" />
    <preference name="FadeSplashScreen" value="true" />
    <preference name="FadeSplashScreenDuration" value=".25" />
    <preference name="HideKeyboardFormAccessoryBar" value="false" />
    <preference name="KeyboardDisplayRequiresUserAction" value="true" />
    <preference name="KeyboardShrinksView" value="false" />
    <preference name="MediaPlaybackRequiresUserAction" value="false" />
    <preference name="ShowSplashScreenSpinner" value="true" />
    <preference name="SuppressesIncrementalRendering" value="false" />
    <preference name="TopActivityIndicator" value="gray" />

    <content src="index.html" />

    <plugins>
        <plugin name="Device" value="CDVDevice" />
        <plugin name="Logger" value="CDVLogger" />
        <plugin name="Compass" value="CDVLocation" />
        <plugin name="Accelerometer" value="CDVAccelerometer" />
        <plugin name="Camera" value="CDVCamera" />
        <plugin name="NetworkStatus" value="CDVConnection" />
        <plugin name="Contacts" value="CDVContacts" />
        <plugin name="Debug Console" value="CDVDebugConsole" />
        <plugin name="Echo" value="CDVEcho" />
        <plugin name="File" value="CDVFile" />
        <plugin name="FileTransfer" value="CDVFileTransfer" />
        <plugin name="Geolocation" value="CDVLocation" />
        <plugin name="Notification" value="CDVNotification" />
        <plugin name="Media" value="CDVSound" />
        <plugin name="Capture" value="CDVCapture" />
        <plugin name="SplashScreen" value="CDVSplashScreen" />
        <plugin name="Battery" value="CDVBattery" />
        <plugin name="Globalization" value="CDVGlobalization" />
        <plugin name="InAppBrowser" value="CDVInAppBrowser" />

        <platform name="ios">
            <config-file target="config.xml" parent="/*">
                <feature name="InAppPurchaseManager">
                    <param name="ios-package" value="InAppPurchaseManager" />
                </feature>
            </config-file>

            <!-- Note: the ios src is based off src/ios implicitly -->
            <header-file src="InAppPurchaseManager.h" />
            <source-file src="InAppPurchaseManager.m" />
            <framework src="StoreKit.framework" />
        </platform>
    </plugins>
    <access origin="*" />
</widget>

and the .h and .m files are in plugins folder in source of project.

I have also made alert in native

InAppPurchaseManager.m

file in - (void) requestProductData:(CDVInvokedUrlCommand*)command function that doesn't show any alert also .

Was it helpful?

Solution

There is a much more recent and popular iOS IAP plugin here: https://github.com/j3k0/PhoneGap-InAppPurchase-iOS

Eventually it will work better.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top