Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

How to modify / create modules for Appcelerator

Sometimes missing features are annying and they are always threatening to bring a project to a total stillstand.

E.g. only three colors for annotations, or no addroute() method for Android.

As i alredy recompiled the Appcelerator source code and have a lot of geofeatures developed already in javascript and also java for Android and Blackberry, I wonder what would be the way to implement my own geolocation module, or if there is any way to contribute to the development of that module.

It there any concise description, for example with a minimum of sample code how to build your own Appcelerator modules?

I really would like to contribute to a better geolocation module for Android…

Werner

— asked November 28th 2010 by Werner Bogula
  • android
  • appcelerator
  • create
  • modules
0 Comments

3 Answers

  • Module sdk will be available in the upcoming 1.5.0 release. The documentation is available in the programming guides section and you can get a 1.5.0 build from the CI server or build it as you've already done.

    On android you can use different pins for images and specify any color for the pin.

    We accept contributions from the community. If you decide to submit a patch, please do the work in a branch with no other changes on it to make it cleaner to pull. You will also need to sign the contributor license agreement when you get to that point.

    — answered November 28th 2010 by Don Thorp
    permalink
    2 Comments
    • is module development in 1.5 different that what is currently posted here
      http://developer.appcelerator.com/doc/mobile/guides

      — commented November 28th 2010 by Aaron Saunders
    • Thank you,

      I will check that out too.
      Werner

      — commented December 1st 2010 by Werner Bogula
  • Okay, I got it working..

    I just changed the module version in tiapp.xml from 1.2 to 1.5, used the old code, that I had working several months ago, and did a clean build.
    It now works perfectly with the upgrade!

    I must have overseen something when I was first testing it, but anyway, here is my working code:

    var buy = Ti.UI.createButton({
        title: 'Buy',
        color: '#000',
        width: 'auto',
        height: 'auto',
        top: 150,
        font: {fontSize: 12, fontWeight:'bold'},
        textAlign: 'center'
    });
    
    win.add(buy);
    
    Titanium.Storekit = Ti.Storekit = require('ti.storekit');
    
    var myProducts;
    
    buy.addEventListener('click',function(e) {
    
    var product = myProducts;
    
        Ti.Storekit.purchase(product, function(r) {
            if (r.state == Ti.Storekit.FAILED) {
                Ti.UI.createAlertDialog({
                    title: 'Error',
                    message: 'Purchasing product: ' + r.message
                }).show();
            }
            else if (r.state == Ti.Storekit.PURCHASED ||
                r.state == Ti.Storekit.RESTORED) {
                var receipt = r.receipt;
                Ti.Storekit.verifyReceipt(
                    {
                        receipt: receipt,
                        sandbox: false,
                        /*sharedSecret: '<<FOR SUBSCRIPTIONS, PUT YOUR SHARED SECRET FROM ITUNESCONNECT HERE>>',*/
                        callback: function(e) {
                            if (e.success) {
                                if (e.valid) {
                                    Ti.UI.createAlertDialog({
                                        title: 'Success!',
                                        message: 'Receipt verified!'
                                    }).show();
                                }
                                else {
                                    Ti.UI.createAlertDialog({
                                        title: 'Failure?!',
                                        message: 'Receipt verification failed!'
                                    }).show();
                                }
                            }
                            else {
                                Ti.UI.createAlertDialog({
                                    title: 'Error',
                                    message: 'Verifying receipt: ' + e.message
                                }).show();
                            }
                        }
                    });
            }
            else {
                Ti.API.info('Purchasing...');
            }
        });
    });
    
    if (!Ti.Storekit.canMakePayments) {
        Ti.UI.createAlertDialog({
            title: 'Error',
            message: 'Cannot make payments to in-app purchase store'
        }).show();
    }
    else {
    
        Ti.Storekit.requestProducts(['YOURPRODUCTIDHERE'], function(e) {
            if (!e.success) {
                Ti.UI.createAlertDialog({
                    title: 'Error',
                    message: 'Getting products: ' + e.message
                }).show();
                return;
            }
            Ti.API.info('Found products: ' + e.products);
            Ti.API.info('Invalid: ' + e.invalid);
            myProducts = e.products[0];
            for (var i = 0; i < e.products.length; i++) {
    
            }
        });
    
        var restore = Ti.UI.createButton({
            title: 'Restore',
            color: '#000',
            width: 'auto',
            height: 'auto',
            bottom: 150,
            font: {fontSize: 12, fontWeight:'bold'},
            textAlign: 'center'
        });
    
        restore.addEventListener('click', function() {
                Ti.Storekit.restoreCompletedTransactions();
        });
    
        Ti.Storekit.addEventListener('restoredCompletedTransactions', function(evt) {
            Ti.API.info('Finished restoring past purchases!');
            if (evt.error) {
                alert(evt.error);
            }
            else if (evt.transactions == null || evt.transactions.length == 0) {
                alert('There were no transactions to restore!');
            }
            else {
                for (var i = 0; i < evt.transactions.length; i++) {
                    var t = evt.transactions[i];
                    alert({
                        state: t.state,
                        identifier: t.identifier,
                        productIdentifier: t.productIdentifier,
                        quantity: t.quantity,
                        date: t.date,
                        receipt: t.receipt
                    });
                }
            }
        });
    win.add(restore);
    }
    

    Hope that this will help :)

    /Anders

    — answered April 13th 2012 by Anders Oestergaard Nielsen
    permalink
    1 Comment
    • Ooops… Sorry, wrong post! Does anyone know how to delete a post?

      — commented April 13th 2012 by Anders Oestergaard Nielsen
  • on this page you can find the module development guides that should get you started. The examples in the document are pretty "weak" in my opinion, but it is better than nothing

    http://developer.appcelerator.com/doc/mobile/guides

    — answered November 28th 2010 by Aaron Saunders
    permalink
    1 Comment
    • Thank you,

      I will check that out..
      Werner

      — commented December 1st 2010 by Werner Bogula
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.