Link Search Menu Expand Document

Usage

Fetch Offerings

Fetch all offers previously created in our dashboard

  • Glassfy.offerings { (offers, err) in
        if let offering = offers?["premium"] {
            // display your offering's skus
            // offering.name
            for sku in anOffer.skus {
                // sku.extravars
                // sku.product.localizedTitle
                // sku.product.localizedDescription
                // sku.product.price
            }
        }
    }
    
  • [Glassfy offeringsWithCompletion:^(GYOfferings *offers, NSError *err) {
        GYOffering *offering = offers[@"premium"];
        if (offering) {
            // display your offering's skus
            // offering.name
            for (GYSku *sku in a.skus) {
                // sku.extravars
                // sku.product.localizedTitle
                // sku.product.localizedDescription
                // sku.product.price
            }
        }
    }];
    

Fetch Sku

Fetch sku previously created in our dashboard

  • Glassfy.sku(identifier: "premium_weekly") { sku, err in
        if let sku = sku {
            // sku.extravars
            // sku.product.localizedTitle
            // sku.product.localizedDescription
            // sku.product.price
        }
    }
    
  • [Glassfy skuWithIdentifier:@"premium_weekly" completion:^(GYSku *sku, NSError *err) {
        if (sku != nil) {
            // sku.extravars
            // sku.product.localizedTitle
            // sku.product.localizedDescription
            // sku.product.price
        }
    }];
    

Make Purchases

To start the purchase process, you need to get a Sku reference using an offer or directly from the identifier .

  • Glassfy.purchase(sku: premiumSku) { (transaction, e) in
        // update app status accondingly
        if let p = transaction?.permissions["aPermission"] {
            if p.isValid {
                // unlock aFeature
            } else {
                // lock aFeature
            }
        }
    }
    
  • [Glassfy purchaseSku:premiumSku completion:^(GYTransaction *transaction, NSError *err) {
        GYPermissions *permissions = transaction.permissions;
        if (permissions) {
            GYPermission *p = permissions[@"aPermission"]
            if (p.isValid) {
                // unlock aFeature
            }
            else {
                // lock aFeature
            }
        }
    }];
    

Check Permissions

Check all current user’s permission and lock unlock your app feature accordingly.

  • Glassfy.permissions { (permission, err) in
        // update app status accondingly
        if let permissions = permission?.all {
            for p in permissions {
                switch p.permissionIdentifier {
                case "aPermission":
                    if p.isValid {
                        // unlock aFeature
                    } else {
                        // lock aFeature
                    }
                default:
                    print("Permission not handled");
                }
            }
        }
    }
    
  • [Glassfy permissionsWithCompletion:^(GYPermissions *permission, NSError *err) {
        NSArray<GYPermission*> *permissions = permission.all;
        if (permissions) {
            for (GYPermission *p in permissions) {
                switch (p.permissionIdentifier) {
                case @"aPermission":
                    if (p.isValid) {
                        // unlock aFeature
                    }
                    else {
                        // lock aFeature
                    }
                    break;
                default:
                    NSLog(@"Permission not handled");
                    break;
                }
            }
        }
    }];
    

User Properties

Save user attributes as key/value pairs useful to customize campaigns

  • Glassfy.set(userProperty:.token, value: remoteDeviceToken) { properties, err in
        if let p = properties {
            // p.email
            // p.token
            // p.extra
        }
    }
    
  • [Glassfy setUserProperty:GYUserPropertyTypeToken value:remoteDeviceToken completion:^(GYUserProperties *p, NSError *err) {
        if (p != nil) {
            // p.email
            // p.token
            // p.extra
        }
    }];
    

Copyright © 2021 Glassfy.