diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md new file mode 100644 index 0000000..d082760 --- /dev/null +++ b/CONTRIBUTION.md @@ -0,0 +1,8 @@ +“All code contributions made to this project are received under the terms of the Developer's Certificate of Origin v.1.1. +By making a contribution to this project, I certify that: +(a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or +(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to +submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as +indicated in the file; or +(c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. +(d) I understand and agree that this project and the contribution” diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 37ec93a..0000000 --- a/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable (except as stated in this section) patent license to make, have -made, use, offer to sell, sell, import, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets "[]" replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same "printed page" as the copyright notice for easier identification within -third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..03163dc --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,180 @@ +Mozilla Public License +Version 2.0 + +1. Definitions + +1.1. “Contributor” +means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. + +1.2. “Contributor Version” +means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution. + +1.3. “Contribution” +means Covered Software of a particular Contributor. + +1.4. “Covered Software” +means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. + +1.5. “Incompatible With Secondary Licenses” +means + +that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or + +that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. + +1.6. “Executable Form” +means any form of the work other than Source Code Form. + +1.7. “Larger Work” +means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. + +1.8. “License” +means this document. + +1.9. “Licensable” +means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. + +1.10. “Modifications” +means any of the following: + +any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or + +any new file in Source Code Form that contains any Covered Software. + +1.11. “Patent Claims” of a Contributor +means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. + +1.12. “Secondary License” +means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. + +1.13. “Source Code Form” +means the form of the work preferred for making modifications. + +1.14. “You” (or “Your”) +means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. + +2. License Grants and Conditions + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: + +under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and + +under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: + +for any code that a Contributor has removed from Covered Software; or + +for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or + +under Patent Claims infringed by Covered Software in the absence of its Contributions. + +This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. + +3. Responsibilities + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and + +You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + +If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. + +6. Disclaimer of Warranty + +Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer. + +7. Limitation of Liability + +Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You. + +8. Litigation + +Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims. + +9. Miscellaneous + +This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. + +10. Versions of the License + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses + +If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice + +This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - “Incompatible With Secondary Licenses” Notice + +This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0. diff --git a/README.md b/README.md index 354da94..e4deea4 100644 --- a/README.md +++ b/README.md @@ -1,86 +1,294 @@ -Marketo PhoneGap – Plugin - - 1. Initialise Marketo Framework : To make sure that Marketo framework get initiated on app startup of your app add below code under “onDeviceReady: function()”. Also you can add this code to any of your own function. - - @Syntax : - marketo.initialize( - function() { console.log("MarketoSDK Init done."); } , - function(error) { console.log("an error occurred:" + error); }, - 'YOUR_MUNCHKIN_ID', 'YOUR_SECRET_KEY' - ); - - @ parameteres : - - • Success call back : set of extra instruction to be executed if Marketo framework got initialised successfully. - • Failure call back : set of extra instruction to be executed if Marketo framework got failed to initialise . - • MUNCKIN ID : munchkin id which you received from Marketo at time of registration . - • SECRET KEY : secrete key which you received from Marketo at time of registration . - - - 1. Add Lead : To associate new Lead in Marketo server call this code to any of your own function. - - @ Syntax : - marketo.addlead(function(){console.log("MarketoSDK : Lead Added");}, - function(error){ console.log("an error occurred:" + error); }, - 'Lead_JSON_String' - ); - - @ parameteres : - - • Success call back : set of extra instruction to be executed if Marketo framework got initialised successfully. - • Failure call back : set of extra instruction to be executed if Marketo framework got failed to initialise . - • Lead Data : Lead data in Json string format , - Sample Lead Data (with default attributes , you can add custom fields ): - var lead = { - 'firstName': 'frist name', - 'lastName': 'last name', - 'address': 'demo address', - 'city': 'city', - 'state': 'state', - 'country': 'country', - 'postalCode': 'postalCode', - 'gender': 'gender', - 'email': 'email', - 'twitterId': 'twitterId', - 'facebookId': 'facebookId', - 'linkedInId': 'linkedInId', - 'leadSource': 'leadSource', - 'dateOfBirth': 'dateOfBirth', - 'facebookProfileURL': 'facebookProfileURL', - 'facebookPhotoURL': 'facebookPhotoURL' - } - - 1. Report Action : To report new action in Marketo server call this code to any of your own function. - - @ Syntax : - marketo.reportaction(function(){console.log("MarketoSDK : New event sent ");}, - function(error){ console.log("an error occurred:" + error); }, - 'custome_report_name','custome_report_data' - ); - - @ parameteres : - - • Success call back : set of extra instruction to be executed if Marketo framework got initialised successfully. - • Failure call back : set of extra instruction to be executed if Marketo framework got failed to initialise . - • Action Name : Action name for the report. - • Action Data : report data in Json string format , - Sample report Data (with default attributes , you can add custom fields ): - var event = { - 'Action Type':'push', - 'Action Details':'event Details', - 'Action Metric':'metric', - 'Action Length':'length' - } - - 1. Http Time Out : To change default http timeout in Marketo sdk call this code to any of your own function. - - @ Syntax : - - marketo.settimeout(function(){console.log("MarketoSDK : Timeout Chnaged");}, - function(error){ console.log("an error occurred:" + error); }, 10 ); - - @ parameteres : - - • Success call back : set of extra instruction to be executed if Marketo framework got initialised successfully. - • Failure call back : set of extra instruction to be executed if Marketo framework got failed to initialise . - • Timeout integer value : timeout Value in integer . +# Marketo Mobile SDK for PhoneGap + +The Marketo Mobile SDK allows integration with Marketo Mobile Engagement (MME). + +## Plugin Change Log + +v0.7.8 (Dec 10, 2018) +- Added Support for Firebase Cloud Messaging in Android +- Fixed Bugs + +v0.7.7 (May 25, 2018) +- Added Support for Android API Level P (28) +- Fixed Bugs + +v0.7.6 (February 12, 2018) +- Updated Android framework +- Using Android Activity Lifecycle Callbacks + +v0.7.5 (January 4, 2018) +- Updated iOS bundle and framework +- Minimum supported Cordova CLI version: 7.1.0 + +## iOS Change Log +v0.7.6 (September 4, 2018) + - Fixed tap gesture error at In-app + +v0.7.5 (September 8, 2017) +- Fixed build errors and warnings in xCode 9 + +v0.7.4 (July 7, 2017) +- Exposed removeDevicePushToken() method + +v0.7.1 (November 24, 2016) +- Handling notification in loadingOptions for iOS 10 to track tap activity when app is closed. + +v0.7.0 (October 5, 2016) +- Using UNNotification to handle push received while app is in foreground with a local notification + +v0.6.4 (August 23, 2016) +- Exposed method [MarketoSDK reportAll] to immediately send events + +v0.6.3 (July 15, 2016) +- Support for InApp display frequnecy once. + +v0.6.0 (June, 11 2016) +- InApp Notifications + +v0.5.1 - v0.5.3 +- Fixed new_install bug +- Fix for version bug + +v0.5.0 +- Advanced secure access +- Bitcode refactor + +## Android Change Log + +v0.7.6 (January 18, 2018) +- Added support for Android API Levels 26 and 27 +- Using Android Activity Lifecycle Callbacks +- Deprecated Marketo.onStart() and Marketo.onStop(), no longer required +- The minimum supported Android API Level is now 14 + +v0.7.5 (July 7, 2017) +- Fixed bug + +v0.7.3 - v0.7.4 (July 7, 2017) +- Exposed removeDevicePushToken() method +- Notifications are now dismissed from the notification center after tap (Android 4.0) +- Custom large notification icon no longer shows default image (Android 4.0) + +v0.7.2 (November 30, 2016) +- Fixed bug when using Priority method in Android versions previous to 5.0 +- Default sound in Android is now on when user receives a notification +- Android Push Notification text now wrap to make it more readable +- Migrated from HttpClient to HttpURLConnection + +v0.7.1 (November 4, 2016) +- Remove GET_ACCOUNTS permission check +- No longer stacking push notifications +- Catching client protocol exception + +v0.7.0 (October 13, 2016) +- Supporting Android Version 7.0 + +v0.6.4 (August 22, 2016) +- Exposed method [MarketoSDK reportAll] to immediately send events + +v0.6.3 (July 15, 2016) +- Bug fixes related to inapp +- added display frequency 'once' + +v0.6.0 (June 10, 2016) +- InApp Notifications + +v0.5.3 +- Fixed bug that stop push notification when app was closed + +v0.5.2 +- Removed depricated android methods to allow building with Proguard + +v0.5.1 +- Fixed intent.getAction condition + +v0.5.0 +- New secure access feature +- New app type selection +- Android notificaiton config large icon + +## Contributing Code + +We accept pull requests! Please raise a merge request. + +## Issues + +If you encounter issues using or integrating this plugin, please file a support ticket at support.marketo.com + +## Marketo PhoneGap Plugin Installation Guide + +### Prerequisites +1. Register an application in Marketo Admin portal, get your application secret key and munchkin id. +2. Configure Android Push access [learn here](http://docs.marketo.com/display/public/DOCS/Configure+Mobile+App+Android+Push+Access) +3. Configure iOS Push access [learn here](https://docs.marketo.com/display/public/DOCS/Configure+Mobile+App+iOS+Push+Access) + +### Setup Marketo PhoneGap plugin + +1. Install Marketo PhoneGap Plugin using PhoneGap/Cordova CLI *(Minimum supported version: 7.1.0)*: Please follow below steps or ensure you have latest cordova version installed on the system [learn more](https://cordova.apache.org/docs/en/latest/guide/cli/) +2. Once it’s ready go to your PhoneGap application directory and run following command. + +```javascript +cordova plugin add https://github.com/Marketo/PhoneGapPlugin.git --variable APPLICATION_SECRET_KEY="YOUR_APPLICATION_SECRET" +``` + +### Migrate to newer version + +```javascript +// This command will remove existing marketo plugin +cordova plugin remove com.marketo.plugin + +// This command will add it again. +cordova plugin add https://github.com/Marketo/PhoneGapPlugin.git --variable APPLICATION_SECRET_KEY="YOUR_APPLICATION_SECRET" +``` + +This will add Marketo Plugin into your phonegap application. + +### Cordova version 8.0.0 (Cordova@Android7.0.0) and above + +Once the Cordova Android platform is built, open the app with Android Studio and update the dirs value of the -Marketo.gradle file found in the com.marketo.plugin folder. + +```javascript +repositories{ + jcenter() + flatDir{ + dirs '../app/src/main/aar' + } +} +``` + +## Track Push Notifications +1. Paste the following code inside the application:didFinishLaunchingWithOptions: function. + +###### Objective-C +```Objective-C +Marketo *sharedInstance = [Marketo sharedInstance]; +[sharedInstance trackPushNotification:launchOptions]; + +``` +###### Swift +```Swift +let sharedInstance: Marketo = Marketo.sharedInstance() +sharedInstance.trackPushNotification(launchOptions) +``` + +## Initialize Marketo Framework +1. After successful installation, you need to initialize Marketo framework. +2. Open your main js file and Add the following code under “onDeviceReady: function()”. + +```javascript +// This method will Initialize the Marketo Framework using Your MunchkinId and secret key +marketo.initialize( + function() { console.log("MarketoSDK Init done."); } , + function(error) { console.log("an error occurred:" + error); }, + 'YOUR_MUNCHKIN_ID', 'YOUR_SECRET_KEY' +); + +// For session tracking, please add following. +marketo.onStart( + function(){console.log("onStart.");}, + function(error){console.log("Failed to report onStart." + error);} +); +``` +### Initialize Marketo Push Notification : +1. After Initializing Marketo SDK successfully , you need to setup push notification. +2. Open your main js file and Add the following code under “onDeviceReady: function()” after marketo.initialize function. + +```javascript +// This function will Enable user notifications (will prompt the user to accept push notifications in iOS) +marketo. initializeMarketoPush( + function() { console.log("Marketo push successfully initialized."); } , + function(error) { console.log("an error occurred:" + error); }, + GCM_PROJECT_ID // this is required for Android and will be ignored in iOS +); +``` +Note: You can get your GCM Project ID from Google Developer Console https://console.developers.google.com/ + +######The token can also be unregistered when user logs out. + +```javascript +marketo. uninitializeMarketoPush( + function() { console.log("Marketo push successfully uninitialized."); } , + function(error) { console.log("an error occurred:" + error); } +); +``` + +### Marketo Associate Lead: +1. You can create a Marketo Lead by calling associate lead method. + +```javascript + // First create a lead as below + var lead_obj = {}; + lead_obj[marketo.KEY_FIRST_NAME]= "John"; + lead_obj[marketo.KEY_LAST_NAME]= "Erickson"; + lead_obj[marketo.KEY_EMAIL]= "johnE@marketo.com"; + lead_obj[marketo.KEY_ADDRESS]= "901 Mariners Island Boulevard"; + lead_obj[marketo.KEY_CITY]= "San Mateo"; + lead_obj[marketo.KEY_STATE]= "CA"; + lead_obj[marketo.KEY_COUNTRY]= "USA"; + lead_obj[marketo.KEY_POSTAL_CODE]= "94404"; + lead_obj[marketo.KEY_GENDER]= "Male"; + + // Use associate function to associate it. + marketo.associateLead( + function() { + console.log("MarketoSDK : Lead Associated"); + }, + function(error) { + console.log("an error occurred:" + error); + }, + JSON.stringify(lead_obj) + ); +``` + +### Marketo Report Action: +1. You can report any user performed action by calling the reportaction method. + +```javascript + // First create an event as below + var event = { + "Action Type":"Add To Cart", + "Action Details":"Adding Product in cart", + "Action Metric":"10", + "Action Length":"1" + } + + marketo.reportaction( + function(){console.log("Reported Action Successfully.");}, + function(error){console.log("Failed to report Action." + error);}, + "Add To Cart", + JSON.stringify(event) + ); +``` + +###Marketo Report All Actions: +1. You can report any user performed action by calling the reportaction method. + +```javascript + marketo.reportAll( + function(){console.log("Reported All Actions Successfully.");}, + function(error){console.log("Failed to report Actions." + error);} + ); +``` + +### Marketo session reporting +1. Bind pause and resume events as show below to report Start and stop to track time spent in mobile application.(Note this is required in android) +. +```javascript + //Add the following code in your www/js/index.js + + bindEvents: function() { + document.addEventListener('deviceready', this.onDeviceReady, false); + document.addEventListener('pause', this.onStop, false); + document.addEventListener('resume', this.onStart, false); + }, + onStop: function() { + marketo.onStop( + function(){console.log("onStop");}, + function(error){console.log("Failed to report onStop." + error);}); + }, + onStart: function() { + marketo.onStart( + function(){console.log("onStart.");}, + function(error){console.log("Failed to report onStart." + error);}); + }, + ``` diff --git a/Scripts/after_prepare.js b/Scripts/after_prepare.js new file mode 100644 index 0000000..4f58240 --- /dev/null +++ b/Scripts/after_prepare.js @@ -0,0 +1,48 @@ +#!/usr/bin/env node + +'use strict'; +var fs = require('fs'); +var path = require('path'); +var utilities = require("./lib/utilities"); + +var config = fs.readFileSync('config.xml').toString(); +var name = utilities.getValue(config, 'name'); + +var ANDROID_DIR = 'platforms/android'; +var IOS_DIR = 'platforms/ios'; + +var PLATFORM = { + ANDROID: { + dest: [ + ANDROID_DIR + '/google-services.json', + ANDROID_DIR + '/app/google-services.json' + ], + src: [ + 'google-services.json', + ANDROID_DIR + '/assets/www/google-services.json', + 'www/google-services.json', + ANDROID_DIR + '/app/src/main/google-services.json' + ], + } +}; + +module.exports = function (context) { + //get platform from the context supplied by cordova + var platforms = context.opts.platforms; + // Copy key files to their platform specific folders + if (platforms.indexOf('ios') !== -1 && utilities.directoryExists(IOS_DIR)) { + /* + If firebase needs to be supported for iOS there has to be a bit more than just copying the key. + Note in the documentation - https://firebase.google.com/docs/ios/setup, the config files isa + `plist`. + */ + + // console.log('Preparing Firebase on iOS'); + // utilities.copyKey(PLATFORM.IOS); + } + + if (platforms.indexOf('android') !== -1 && utilities.directoryExists(ANDROID_DIR)) { + console.log('Preparing Firebase on Android'); + utilities.copyKey(PLATFORM.ANDROID); + } +}; diff --git a/Scripts/android/after_plugin_install.js b/Scripts/android/after_plugin_install.js new file mode 100644 index 0000000..d5a0e40 --- /dev/null +++ b/Scripts/android/after_plugin_install.js @@ -0,0 +1,9 @@ +var helper = require('./helper'); + +module.exports = function(context) { + + // Modify the Gradle build file to add a task that will upload the debug symbols + // at build time. + helper.restoreRootBuildGradle(); + helper.modifyRootBuildGradle(); +}; diff --git a/Scripts/android/before_plugin_uninstall.js b/Scripts/android/before_plugin_uninstall.js new file mode 100644 index 0000000..717fcfc --- /dev/null +++ b/Scripts/android/before_plugin_uninstall.js @@ -0,0 +1,7 @@ +var helper = require('./helper'); + +module.exports = function(context) { + + // Remove the Gradle modifications that were added when the plugin was installed. + helper.restoreRootBuildGradle(); +}; diff --git a/Scripts/android/helper.js b/Scripts/android/helper.js new file mode 100644 index 0000000..99abb52 --- /dev/null +++ b/Scripts/android/helper.js @@ -0,0 +1,117 @@ +var fs = require("fs"); +var path = require("path"); + +function rootBuildGradleExists() { + var target = path.join("platforms", "android", "build.gradle"); + return fs.existsSync(target); +} + +/* + * Helper function to read the build.gradle that sits at the root of the project + */ +function readRootBuildGradle() { + var target = path.join("platforms", "android", "build.gradle"); + return fs.readFileSync(target, "utf-8"); +} + +/* + * Added a dependency on 'com.google.gms' based on the position of the know 'com.android.tools.build' dependency in the build.gradle + */ +function addDependencies(buildGradle) { + // find the known line to match + var match = buildGradle.match(/^(\s*)classpath 'com.android.tools.build(.*)/m); + var whitespace = match[1]; + + // modify the line to add the necessary dependencies + var googlePlayDependency = whitespace + "classpath \'com.google.gms:google-services:4.1.0\'" // google-services dependency from Marketo SDK; + var fabricDependency = whitespace + "classpath \'io.fabric.tools:gradle:1.25.4\'" // fabric dependency from Marketo SDK + var modifiedLine = match[0] + '\n' + googlePlayDependency + '\n' + fabricDependency; + + // modify the actual line + return buildGradle.replace(/^(\s*)classpath 'com.android.tools.build(.*)/m, modifiedLine); +} + +/* + * Add 'google()' and Crashlytics to the repository repo list + */ +function addRepos(buildGradle) { + // find the known line to match + var match = buildGradle.match(/^(\s*)jcenter\(\)/m); + var whitespace = match[1]; + + // modify the line to add the necessary repo + // Crashlytics goes under buildscripts which is the first grouping in the file + var fabricMavenRepo = whitespace + "maven { url \"https://maven.fabric.io/public\" }" // Fabrics Maven repository from Marketo SDK + var googlesMavenRepo = whitespace + "google()" // Google\'s Maven repository from Marketo SDK; + var modifiedLine = match[0] + '\n' + fabricMavenRepo + '\n'+ googlesMavenRepo; + + // modify the actual line + buildGradle = buildGradle.replace(/^(\s*)jcenter\(\)/m, modifiedLine); + + // update the all projects grouping + var allProjectsIndex = buildGradle.indexOf('allprojects'); + if (allProjectsIndex > 0) { + // split the string on allprojects because jcenter is in both groups and we need to modify the 2nd instance + var firstHalfOfFile = buildGradle.substring(0, allProjectsIndex); + var secondHalfOfFile = buildGradle.substring(allProjectsIndex); + + // Add google() to the allprojects section of the string + match = secondHalfOfFile.match(/^(\s*)jcenter\(\)/m); + modifiedLine = match[0] + '\n' + googlesMavenRepo; + // modify the part of the string that is after 'allprojects' + secondHalfOfFile = secondHalfOfFile.replace(/^(\s*)jcenter\(\)/m, modifiedLine); + + // recombine the modified line + buildGradle = firstHalfOfFile + secondHalfOfFile; + } else { + // this should not happen, but if it does, we should try to add the dependency to the buildscript + match = buildGradle.match(/^(\s*)jcenter\(\)/m); + modifiedLine = match[0] + '\n' + googlesMavenRepo; + // modify the part of the string that is after 'allprojects' + buildGradle = buildGradle.replace(/^(\s*)jcenter\(\)/m, modifiedLine); + } + + return buildGradle; +} + +/* + * Helper function to write to the build.gradle that sits at the root of the project + */ +function writeRootBuildGradle(contents) { + var target = path.join("platforms", "android", "build.gradle"); + fs.writeFileSync(target, contents); +} + +module.exports = { + + modifyRootBuildGradle: function() { + // be defensive and don't crash if the file doesn't exist + if (!rootBuildGradleExists) { + return; + } + + var buildGradle = readRootBuildGradle(); + + // Add Google Play Services Dependency + buildGradle = addDependencies(buildGradle); + + // Add Google's Maven Repo + buildGradle = addRepos(buildGradle); + + writeRootBuildGradle(buildGradle); + }, + + restoreRootBuildGradle: function() { + // be defensive and don't crash if the file doesn't exist + if (!rootBuildGradleExists) { + return; + } + + var buildGradle = readRootBuildGradle(); + + // remove any lines we added + buildGradle = buildGradle.replace(/(?:^|\r?\n)(.*)Marketo SDK*?(?=$|\r?\n)/g, ''); + + writeRootBuildGradle(buildGradle); + } +}; diff --git a/Scripts/lib/utilities.js b/Scripts/lib/utilities.js new file mode 100644 index 0000000..7154f60 --- /dev/null +++ b/Scripts/lib/utilities.js @@ -0,0 +1,88 @@ +/** + * Utilities and shared functionality for the build hooks. + */ +var fs = require('fs'); +var path = require("path"); + +fs.ensureDirSync = function (dir) { + if (!fs.existsSync(dir)) { + dir.split(path.sep).reduce(function (currentPath, folder) { + currentPath += folder + path.sep; + if (!fs.existsSync(currentPath)) { + fs.mkdirSync(currentPath); + } + return currentPath; + }, ''); + } +}; + +module.exports = { + /** + * Used to get the name of the application as defined in the config.xml. + * + * @param {object} context - The Cordova context. + * @returns {string} The value of the name element in config.xml. + */ + getAppName: function (context) { + var ConfigParser = context.requireCordovaModule("cordova-lib").configparser; + var config = new ConfigParser("config.xml"); + return config.name(); + }, + + /** + * The ID of the plugin; this should match the ID in plugin.xml. + */ + getPluginId: function () { + return "cordova-plugin-firebase"; + }, + + copyKey: function (platform) { + for (var i = 0; i < platform.src.length; i++) { + var file = platform.src[i]; + if (this.fileExists(file)) { + try { + var contents = fs.readFileSync(file).toString(); + + try { + platform.dest.forEach(function (destinationPath) { + var folder = destinationPath.substring(0, destinationPath.lastIndexOf('/')); + fs.ensureDirSync(folder); + fs.writeFileSync(destinationPath, contents); + }); + } catch (e) { + // skip + } + } catch (err) { + console.log(err); + } + + break; + } + } + }, + + getValue: function (config, name) { + var value = config.match(new RegExp('<' + name + '(.*?)>(.*?)', 'i')); + if (value && value[2]) { + return value[2] + } else { + return null + } + }, + + fileExists: function (path) { + try { + return fs.statSync(path).isFile(); + } catch (e) { + return false; + } + }, + + directoryExists: function (path) { + try { + return fs.statSync(path).isDirectory(); + } catch (e) { + return false; + } + } +}; diff --git a/aar/MarketoRelease.aar b/aar/MarketoRelease.aar new file mode 100644 index 0000000..5efa8f5 Binary files /dev/null and b/aar/MarketoRelease.aar differ diff --git a/build-extras.gradle b/build-extras.gradle new file mode 100644 index 0000000..711e80c --- /dev/null +++ b/build-extras.gradle @@ -0,0 +1,11 @@ +android { + defaultConfig { + minSdkVersion 16 + targetSdkVersion 22 + } + + packagingOptions { + exclude 'META-INF/NOTICE' + exclude 'META-INF/LICENSE' + } +} \ No newline at end of file diff --git a/framework/MKTResources.bundle/Info.plist b/framework/MKTResources.bundle/Info.plist new file mode 100644 index 0000000..259587d Binary files /dev/null and b/framework/MKTResources.bundle/Info.plist differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/2bL-KO-YST-view-a8U-xE-E7G.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/2bL-KO-YST-view-a8U-xE-E7G.nib new file mode 100644 index 0000000..fb91885 Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/2bL-KO-YST-view-a8U-xE-E7G.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/49h-a3-A41-view-fvT-Ft-zfF.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/49h-a3-A41-view-fvT-Ft-zfF.nib new file mode 100644 index 0000000..9784ccb Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/49h-a3-A41-view-fvT-Ft-zfF.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/IPz-a6-TKw-view-10q-5i-bJ8.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/IPz-a6-TKw-view-10q-5i-bJ8.nib new file mode 100644 index 0000000..e5ce7fb Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/IPz-a6-TKw-view-10q-5i-bJ8.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/Info.plist b/framework/MKTResources.bundle/MKTInApp.storyboardc/Info.plist new file mode 100644 index 0000000..1412457 Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/Info.plist differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/IvD-s3-dnV-view-Uch-bF-LzO.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/IvD-s3-dnV-view-Uch-bF-LzO.nib new file mode 100644 index 0000000..4405d44 Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/IvD-s3-dnV-view-Uch-bF-LzO.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout1.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout1.nib new file mode 100644 index 0000000..14e57e4 Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout1.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout2.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout2.nib new file mode 100644 index 0000000..46c2b62 Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout2.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout3.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout3.nib new file mode 100644 index 0000000..2bf1447 Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout3.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout4.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout4.nib new file mode 100644 index 0000000..df3290a Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout4.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout5.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout5.nib new file mode 100644 index 0000000..d9ab0f8 Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout5.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout6.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout6.nib new file mode 100644 index 0000000..ded59fa Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTIALayout6.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTInAppViewControllerFull.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTInAppViewControllerFull.nib new file mode 100644 index 0000000..8efd1bf Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTInAppViewControllerFull.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTInAppViewControllerPop.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTInAppViewControllerPop.nib new file mode 100644 index 0000000..b6541fc Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/MKTInAppViewControllerPop.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/RFy-xF-LKd-view-3Cw-IA-fzl.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/RFy-xF-LKd-view-3Cw-IA-fzl.nib new file mode 100644 index 0000000..6964ed2 Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/RFy-xF-LKd-view-3Cw-IA-fzl.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/gec-So-ihj-view-VZ7-Pz-YT3.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/gec-So-ihj-view-VZ7-Pz-YT3.nib new file mode 100644 index 0000000..28127b2 Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/gec-So-ihj-view-VZ7-Pz-YT3.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/h9i-mR-gP3-view-lkT-LT-HVP.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/h9i-mR-gP3-view-lkT-LT-HVP.nib new file mode 100644 index 0000000..824d0c5 Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/h9i-mR-gP3-view-lkT-LT-HVP.nib differ diff --git a/framework/MKTResources.bundle/MKTInApp.storyboardc/uLc-fR-LY1-view-fxn-nj-gyM.nib b/framework/MKTResources.bundle/MKTInApp.storyboardc/uLc-fR-LY1-view-fxn-nj-gyM.nib new file mode 100644 index 0000000..da18693 Binary files /dev/null and b/framework/MKTResources.bundle/MKTInApp.storyboardc/uLc-fR-LY1-view-fxn-nj-gyM.nib differ diff --git a/framework/MKTResources.bundle/gradient-slice.png b/framework/MKTResources.bundle/gradient-slice.png new file mode 100644 index 0000000..c6d8d98 Binary files /dev/null and b/framework/MKTResources.bundle/gradient-slice.png differ diff --git a/framework/Marketo.framework/Headers/MKTSecuritySignature.h b/framework/Marketo.framework/Headers/MKTSecuritySignature.h new file mode 100644 index 0000000..e8da5b2 --- /dev/null +++ b/framework/Marketo.framework/Headers/MKTSecuritySignature.h @@ -0,0 +1,54 @@ +// +// MKTSecuritySignature +// Marketo +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header MKTSecuritySignature + * @discussion The MKTSecuritySignature class is used for secure communication. + * @updated 2015-04-29 + */ + +#import + +@interface MKTSecuritySignature : NSObject + +/*! + * Returns a MKTSecuritySignature Object . + * @return instance of class MKTSecuritySignature. + */ +- (id)initWithAccessKey:(NSString *)accessKey signature:(NSString *)signature timestamp:(NSString *)timestamp email:(NSString *)email; + +/*! + * Returns a AccessKey . + * @return NSString containing AccessKey + */ +- (NSString *)getAccessKey; + +/*! + * Returns a Signature . + * @return NSString containing Signature + */ +- (NSString *)getSignature; + +/*! + * Returns a TimeStamp . + * @return NSString containing TimeStamp + */ +- (NSString *)getTimeStamp; + +/*! + * Returns a getEmail . + * @return NSString containing Email + */ +- (NSString *)getEmail; + +/*! + * Returns MKTSecuritySignature valid or not . + * @return BOOL for MKTSecuritySignature is Valid . + */ +- (BOOL)isValid; + +@end diff --git a/framework/Marketo.framework/Headers/Marketo.h b/framework/Marketo.framework/Headers/Marketo.h new file mode 100644 index 0000000..311ec7f --- /dev/null +++ b/framework/Marketo.framework/Headers/Marketo.h @@ -0,0 +1,156 @@ +// +// Marketo.h +// +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header Marketo.h + * @discussion The Marketo class is used to initialize the Marketo SDK. + */ + +#import +#import +#import +#import +#import +@interface Marketo : NSObject + +/*! + * Returns the App Secret used to initialize Marketo SDK. + */ +@property (nonatomic, readonly) NSString *appSecret; + +/*! + * Returns a singleton that is an instance of Marketo SDK. + * @return Singleton instance of class Marketo. + */ ++ (Marketo *)sharedInstance; + +/*! + * Initializes Marketo SDK. This method should be called before calling any other Marketo SDK method. + * @param appSecret An app secret used to initialize the app + * @param munchkinID Used to connect to marketo end-point + */ +- (void)initializeWithMunchkinID:(NSString *)munchkinID appSecret:(NSString *)appSecret launchOptions:(NSDictionary *)launchOptions; + +/*! + * The timeout interval, in seconds. If during a connection attempt the request remains idle for longer + * than the timeout interval, the request is considered to have timed out. + * The default timeout interval is 10 seconds. + */ +- (void)setTimeoutInterval:(NSInteger)seconds; + +/*! + * Reports an action to the Marketo server + * @param actionName The action to be reported + * @param metaData Optional - Use the setter methods to send metadata + * ex:- { + * "Action Type":"Shopping", + * "Action Details":"RedShirt", + * "Action Metric":10, + * "Action Length":30 + * } + */ +- (void)reportAction:(NSString *)actionName withMetaData:(MarketoActionMetaData *)metaData; + +/*! + * This function updates a single lead record from Marketo. + * If a lead without a matching email isn't found in the database, a new one is created + * @param lead Marketo Lead Object + */ +- (void)associateLead:(MarketoLead *)lead; + +/*! + * This function registers a Push Token. + * If a Push Token is already registered, just use registered token. + * @param deviceToken Token in form of NSData + */ +- (void)registerPushDeviceToken:(NSData *)deviceToken; + +/*! + * This function unregisters a Push Token. + * If a Push Token is already registered, call unregisterPushDeviceToken to unregister token. + */ +- (void)unregisterPushDeviceToken; + +/*! + * This tracks the push notification by sending an activity. + * @param userInfo Dictionary containing push payload + */ +- (void)trackPushNotification:(NSDictionary *)userInfo; + +/*! + * This function allows you to handle a push notificaiton appropriatly. + * @param userInfo Dictionary containing push payload + */ +- (void)handlePushNotification:(NSDictionary *)userInfo; + +/*! + * This function checks to see if a push token is already registered. + * @return true if push token has already been registered + */ +- (BOOL)isPushRegistered; + +/*! + * Deep link handler for Marketo Url and scheema + * @param application The singleton app object + * @param url The URL resource to open. This resource can be a network resource or a file. For information about the Apple-registered URL schemes, see + * @param sourceApplication The bundle ID of the app that is requesting your app to open the URL (url) + * @param annotation A property list object supplied by the source app to communicate information to the receiving app. + */ +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; + +/*! +* Override System's didReceiveLocalNotification method to Operate PushNotification +* @param application The singleton app object + * @param notification UILocalNotification object supplied by the source app. +*/ +- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification; + +/*! + * Override System's userNotificationCenter method to Operate PushNotification + * @param center The UNUserNotificationCenter object supplied by the source app. + * @param response UNNotificationResponse object supplied by the source app. + * @param completionHandler object supplied by the source app. + */ +- (void)userNotificationCenter:(UNUserNotificationCenter *)center +didReceiveNotificationResponse:(UNNotificationResponse *)response + withCompletionHandler:(void(^)())completionHandler; +/*! + * Set security Signature for Authentication + * @param token - The Security Token recived from client server + */ +- (void)setSecureSignature:(MKTSecuritySignature *)conf; + +/*! + * Remove security Signature from SDK . + * + */ +- (void)removeSecureSignature; + +/*! + * Returns a BOOL for the SDK enabled the Secure mode or not . + * + */ +- (BOOL)isSecureModeEnabled; + +/*! + * Returns a Device ID used by SDK. + * + */ +- (NSString *)getDeviceId; + +/*! + * Force report all data to Server. + * + */ +- (void)reportAll; + +/*! + * This object should be initialized via shared instance + */ +- (id)init __attribute__ ((unavailable ("cannot use init for this class, use +(Marketo*)sharedInstance instead"))); + +@end diff --git a/framework/Marketo.framework/Headers/MarketoActionMetaData.h b/framework/Marketo.framework/Headers/MarketoActionMetaData.h new file mode 100644 index 0000000..fef6346 --- /dev/null +++ b/framework/Marketo.framework/Headers/MarketoActionMetaData.h @@ -0,0 +1,56 @@ +// +// MarketoActionMetadata.h +// +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header MarketoActionMetaData.h + * @discussion The MarketoActionMetaData class is used to encapsulate the action's metadata. + * @updated 2015-04-29 + */ + +#import + +@interface MarketoActionMetaData : NSObject + +- (id)init; + +/*! + * Set the action type + * @param type String phrase that describes the type of action + */ +- (void)setType:(NSString *)type; + +/*! + * Set the action details + * @param details String that contains more details about the action + */ +- (void)setDetails:(NSString *)details; + +/*! + * Set the action metric + * @param metric Number that represents the metric of the action + */ +- (void)setMetric:(NSNumber *)metric; + +/*! + * Set the action length + * @param length Number that represents the length of the action + */ +- (void)setLength:(NSNumber *)length; + +///*! +// * Set custom action metadata. +// * @param value String containing the value of the custom field +// */ +//-(void) setFieldName:(NSString *) name withValue:(NSString *) value; + +/*! + * Return action metadata. + * @return userData Dictionary containing action metadata + */ +- (NSDictionary *)actionMetadata; + +@end \ No newline at end of file diff --git a/framework/Marketo.framework/Headers/MarketoLead.h b/framework/Marketo.framework/Headers/MarketoLead.h new file mode 100644 index 0000000..0a4fa0a --- /dev/null +++ b/framework/Marketo.framework/Headers/MarketoLead.h @@ -0,0 +1,128 @@ +// +// MarketoLead.h +// +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header MarketoLead.h + * @discussion The MarketoLead class is used associate a lead with attributes gathered by the application. + * @updated 2015-04-29 + */ + +#import + +@interface MarketoLead : NSObject + +- (id)init; + +/*! + * Update the lead's email. + * @param email The email to be associated with the device + */ +- (void)setEmail:(NSString *)email; + +/*! + * Update the lead's gender. + * @param gender String that represents lead's gender. ex. male, female + */ +- (void)setGender:(NSString *)gender; + +/*! + * Update the lead's first name. + * @param firstName String containing lead's first name + */ +- (void)setFirstName:(NSString *)firstName; + +/*! + * Update the lead's last name. + * @param lastName String containing lead's last name + */ +- (void)setLastName:(NSString *)lastName; + +/*! + * Update the lead's address. + * @param address String containing address of the lead + */ +- (void)setAddress:(NSString *)address; + +/*! + * Update the lead's city. + * @param city String containing name of the lead's city name + */ +- (void)setCity:(NSString *)city; + +/*! + * Update the lead's state. + * @param state String containing the lead's state name + */ +- (void)setState:(NSString *)state; + +/*! + * Update the lead's country. + * @param country String containing the lead's country name + */ +- (void)setCountry:(NSString *)country; + +/*! + * Update the lead's zipcode. + * @param postalCode String containing then lead's postal code + */ +- (void)setPostalCode:(NSString *)postalCode; + +/*! + * Update the lead's install source. ex. _facebookAds or bannerAds. + * @param leadSource String containing the lead's source + */ +- (void)setLeadSource:(NSString *)leadSource; + +/*! + * Update the lead's facebook id. + * @param facebookId String that contains the lead's facebook id + */ +- (void)setFacebookId:(NSString *)facebookId; + +/*! + * Update the lead's twitter id. + * @param twitterId String that contains the lead's twitter id + */ +- (void)setTwitterId:(NSString *)twitterId; + +/*! + * Update the lead's Linkedin id. + * @param LinkedInId String that contains the lead's LinkedIn id + */ +- (void)setLinkedInId:(NSString *)LinkedInId; + +/*! + * Update the lead's users birthday. + * @param birthday String that contains the lead's birthday with format MM/DD/YYYY + */ +- (void)setBirthDay:(NSString *)birthday; + +/*! + * Update the lead's facebook profile page url. + * @param url String that contains the url of the lead's Facebook profile page + */ +- (void)setFacebookProfileURL:(NSString *)url; + +/*! + * Update the lead's facebook profile picture url. + * @param url String that contains the url of the lead's Facebook profile picture + */ +- (void)setFacebookProfilePicURL:(NSString *)url; + +/*! + * Update the lead's custom attributes. + * @param value String that represents the value of the custom field + */ +- (void)setFieldName:(NSString *)name withValue:(NSString *)value; + +/*! + * Return lead attributes. + * @return userData Dictionary containing leadData + */ +- (NSDictionary *)userData; + +@end diff --git a/framework/Marketo.framework/Marketo b/framework/Marketo.framework/Marketo new file mode 100644 index 0000000..0c0852f Binary files /dev/null and b/framework/Marketo.framework/Marketo differ diff --git a/framework/Marketo.framework/Versions/A/Headers/MKTSecuritySignature.h b/framework/Marketo.framework/Versions/A/Headers/MKTSecuritySignature.h new file mode 100644 index 0000000..e8da5b2 --- /dev/null +++ b/framework/Marketo.framework/Versions/A/Headers/MKTSecuritySignature.h @@ -0,0 +1,54 @@ +// +// MKTSecuritySignature +// Marketo +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header MKTSecuritySignature + * @discussion The MKTSecuritySignature class is used for secure communication. + * @updated 2015-04-29 + */ + +#import + +@interface MKTSecuritySignature : NSObject + +/*! + * Returns a MKTSecuritySignature Object . + * @return instance of class MKTSecuritySignature. + */ +- (id)initWithAccessKey:(NSString *)accessKey signature:(NSString *)signature timestamp:(NSString *)timestamp email:(NSString *)email; + +/*! + * Returns a AccessKey . + * @return NSString containing AccessKey + */ +- (NSString *)getAccessKey; + +/*! + * Returns a Signature . + * @return NSString containing Signature + */ +- (NSString *)getSignature; + +/*! + * Returns a TimeStamp . + * @return NSString containing TimeStamp + */ +- (NSString *)getTimeStamp; + +/*! + * Returns a getEmail . + * @return NSString containing Email + */ +- (NSString *)getEmail; + +/*! + * Returns MKTSecuritySignature valid or not . + * @return BOOL for MKTSecuritySignature is Valid . + */ +- (BOOL)isValid; + +@end diff --git a/framework/Marketo.framework/Versions/A/Headers/Marketo.h b/framework/Marketo.framework/Versions/A/Headers/Marketo.h new file mode 100644 index 0000000..311ec7f --- /dev/null +++ b/framework/Marketo.framework/Versions/A/Headers/Marketo.h @@ -0,0 +1,156 @@ +// +// Marketo.h +// +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header Marketo.h + * @discussion The Marketo class is used to initialize the Marketo SDK. + */ + +#import +#import +#import +#import +#import +@interface Marketo : NSObject + +/*! + * Returns the App Secret used to initialize Marketo SDK. + */ +@property (nonatomic, readonly) NSString *appSecret; + +/*! + * Returns a singleton that is an instance of Marketo SDK. + * @return Singleton instance of class Marketo. + */ ++ (Marketo *)sharedInstance; + +/*! + * Initializes Marketo SDK. This method should be called before calling any other Marketo SDK method. + * @param appSecret An app secret used to initialize the app + * @param munchkinID Used to connect to marketo end-point + */ +- (void)initializeWithMunchkinID:(NSString *)munchkinID appSecret:(NSString *)appSecret launchOptions:(NSDictionary *)launchOptions; + +/*! + * The timeout interval, in seconds. If during a connection attempt the request remains idle for longer + * than the timeout interval, the request is considered to have timed out. + * The default timeout interval is 10 seconds. + */ +- (void)setTimeoutInterval:(NSInteger)seconds; + +/*! + * Reports an action to the Marketo server + * @param actionName The action to be reported + * @param metaData Optional - Use the setter methods to send metadata + * ex:- { + * "Action Type":"Shopping", + * "Action Details":"RedShirt", + * "Action Metric":10, + * "Action Length":30 + * } + */ +- (void)reportAction:(NSString *)actionName withMetaData:(MarketoActionMetaData *)metaData; + +/*! + * This function updates a single lead record from Marketo. + * If a lead without a matching email isn't found in the database, a new one is created + * @param lead Marketo Lead Object + */ +- (void)associateLead:(MarketoLead *)lead; + +/*! + * This function registers a Push Token. + * If a Push Token is already registered, just use registered token. + * @param deviceToken Token in form of NSData + */ +- (void)registerPushDeviceToken:(NSData *)deviceToken; + +/*! + * This function unregisters a Push Token. + * If a Push Token is already registered, call unregisterPushDeviceToken to unregister token. + */ +- (void)unregisterPushDeviceToken; + +/*! + * This tracks the push notification by sending an activity. + * @param userInfo Dictionary containing push payload + */ +- (void)trackPushNotification:(NSDictionary *)userInfo; + +/*! + * This function allows you to handle a push notificaiton appropriatly. + * @param userInfo Dictionary containing push payload + */ +- (void)handlePushNotification:(NSDictionary *)userInfo; + +/*! + * This function checks to see if a push token is already registered. + * @return true if push token has already been registered + */ +- (BOOL)isPushRegistered; + +/*! + * Deep link handler for Marketo Url and scheema + * @param application The singleton app object + * @param url The URL resource to open. This resource can be a network resource or a file. For information about the Apple-registered URL schemes, see + * @param sourceApplication The bundle ID of the app that is requesting your app to open the URL (url) + * @param annotation A property list object supplied by the source app to communicate information to the receiving app. + */ +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; + +/*! +* Override System's didReceiveLocalNotification method to Operate PushNotification +* @param application The singleton app object + * @param notification UILocalNotification object supplied by the source app. +*/ +- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification; + +/*! + * Override System's userNotificationCenter method to Operate PushNotification + * @param center The UNUserNotificationCenter object supplied by the source app. + * @param response UNNotificationResponse object supplied by the source app. + * @param completionHandler object supplied by the source app. + */ +- (void)userNotificationCenter:(UNUserNotificationCenter *)center +didReceiveNotificationResponse:(UNNotificationResponse *)response + withCompletionHandler:(void(^)())completionHandler; +/*! + * Set security Signature for Authentication + * @param token - The Security Token recived from client server + */ +- (void)setSecureSignature:(MKTSecuritySignature *)conf; + +/*! + * Remove security Signature from SDK . + * + */ +- (void)removeSecureSignature; + +/*! + * Returns a BOOL for the SDK enabled the Secure mode or not . + * + */ +- (BOOL)isSecureModeEnabled; + +/*! + * Returns a Device ID used by SDK. + * + */ +- (NSString *)getDeviceId; + +/*! + * Force report all data to Server. + * + */ +- (void)reportAll; + +/*! + * This object should be initialized via shared instance + */ +- (id)init __attribute__ ((unavailable ("cannot use init for this class, use +(Marketo*)sharedInstance instead"))); + +@end diff --git a/framework/Marketo.framework/Versions/A/Headers/MarketoActionMetaData.h b/framework/Marketo.framework/Versions/A/Headers/MarketoActionMetaData.h new file mode 100644 index 0000000..fef6346 --- /dev/null +++ b/framework/Marketo.framework/Versions/A/Headers/MarketoActionMetaData.h @@ -0,0 +1,56 @@ +// +// MarketoActionMetadata.h +// +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header MarketoActionMetaData.h + * @discussion The MarketoActionMetaData class is used to encapsulate the action's metadata. + * @updated 2015-04-29 + */ + +#import + +@interface MarketoActionMetaData : NSObject + +- (id)init; + +/*! + * Set the action type + * @param type String phrase that describes the type of action + */ +- (void)setType:(NSString *)type; + +/*! + * Set the action details + * @param details String that contains more details about the action + */ +- (void)setDetails:(NSString *)details; + +/*! + * Set the action metric + * @param metric Number that represents the metric of the action + */ +- (void)setMetric:(NSNumber *)metric; + +/*! + * Set the action length + * @param length Number that represents the length of the action + */ +- (void)setLength:(NSNumber *)length; + +///*! +// * Set custom action metadata. +// * @param value String containing the value of the custom field +// */ +//-(void) setFieldName:(NSString *) name withValue:(NSString *) value; + +/*! + * Return action metadata. + * @return userData Dictionary containing action metadata + */ +- (NSDictionary *)actionMetadata; + +@end \ No newline at end of file diff --git a/framework/Marketo.framework/Versions/A/Headers/MarketoLead.h b/framework/Marketo.framework/Versions/A/Headers/MarketoLead.h new file mode 100644 index 0000000..0a4fa0a --- /dev/null +++ b/framework/Marketo.framework/Versions/A/Headers/MarketoLead.h @@ -0,0 +1,128 @@ +// +// MarketoLead.h +// +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header MarketoLead.h + * @discussion The MarketoLead class is used associate a lead with attributes gathered by the application. + * @updated 2015-04-29 + */ + +#import + +@interface MarketoLead : NSObject + +- (id)init; + +/*! + * Update the lead's email. + * @param email The email to be associated with the device + */ +- (void)setEmail:(NSString *)email; + +/*! + * Update the lead's gender. + * @param gender String that represents lead's gender. ex. male, female + */ +- (void)setGender:(NSString *)gender; + +/*! + * Update the lead's first name. + * @param firstName String containing lead's first name + */ +- (void)setFirstName:(NSString *)firstName; + +/*! + * Update the lead's last name. + * @param lastName String containing lead's last name + */ +- (void)setLastName:(NSString *)lastName; + +/*! + * Update the lead's address. + * @param address String containing address of the lead + */ +- (void)setAddress:(NSString *)address; + +/*! + * Update the lead's city. + * @param city String containing name of the lead's city name + */ +- (void)setCity:(NSString *)city; + +/*! + * Update the lead's state. + * @param state String containing the lead's state name + */ +- (void)setState:(NSString *)state; + +/*! + * Update the lead's country. + * @param country String containing the lead's country name + */ +- (void)setCountry:(NSString *)country; + +/*! + * Update the lead's zipcode. + * @param postalCode String containing then lead's postal code + */ +- (void)setPostalCode:(NSString *)postalCode; + +/*! + * Update the lead's install source. ex. _facebookAds or bannerAds. + * @param leadSource String containing the lead's source + */ +- (void)setLeadSource:(NSString *)leadSource; + +/*! + * Update the lead's facebook id. + * @param facebookId String that contains the lead's facebook id + */ +- (void)setFacebookId:(NSString *)facebookId; + +/*! + * Update the lead's twitter id. + * @param twitterId String that contains the lead's twitter id + */ +- (void)setTwitterId:(NSString *)twitterId; + +/*! + * Update the lead's Linkedin id. + * @param LinkedInId String that contains the lead's LinkedIn id + */ +- (void)setLinkedInId:(NSString *)LinkedInId; + +/*! + * Update the lead's users birthday. + * @param birthday String that contains the lead's birthday with format MM/DD/YYYY + */ +- (void)setBirthDay:(NSString *)birthday; + +/*! + * Update the lead's facebook profile page url. + * @param url String that contains the url of the lead's Facebook profile page + */ +- (void)setFacebookProfileURL:(NSString *)url; + +/*! + * Update the lead's facebook profile picture url. + * @param url String that contains the url of the lead's Facebook profile picture + */ +- (void)setFacebookProfilePicURL:(NSString *)url; + +/*! + * Update the lead's custom attributes. + * @param value String that represents the value of the custom field + */ +- (void)setFieldName:(NSString *)name withValue:(NSString *)value; + +/*! + * Return lead attributes. + * @return userData Dictionary containing leadData + */ +- (NSDictionary *)userData; + +@end diff --git a/framework/Marketo.framework/Versions/A/Marketo b/framework/Marketo.framework/Versions/A/Marketo new file mode 100644 index 0000000..0c0852f Binary files /dev/null and b/framework/Marketo.framework/Versions/A/Marketo differ diff --git a/framework/Marketo.framework/Versions/Current/Headers/MKTSecuritySignature.h b/framework/Marketo.framework/Versions/Current/Headers/MKTSecuritySignature.h new file mode 100644 index 0000000..e8da5b2 --- /dev/null +++ b/framework/Marketo.framework/Versions/Current/Headers/MKTSecuritySignature.h @@ -0,0 +1,54 @@ +// +// MKTSecuritySignature +// Marketo +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header MKTSecuritySignature + * @discussion The MKTSecuritySignature class is used for secure communication. + * @updated 2015-04-29 + */ + +#import + +@interface MKTSecuritySignature : NSObject + +/*! + * Returns a MKTSecuritySignature Object . + * @return instance of class MKTSecuritySignature. + */ +- (id)initWithAccessKey:(NSString *)accessKey signature:(NSString *)signature timestamp:(NSString *)timestamp email:(NSString *)email; + +/*! + * Returns a AccessKey . + * @return NSString containing AccessKey + */ +- (NSString *)getAccessKey; + +/*! + * Returns a Signature . + * @return NSString containing Signature + */ +- (NSString *)getSignature; + +/*! + * Returns a TimeStamp . + * @return NSString containing TimeStamp + */ +- (NSString *)getTimeStamp; + +/*! + * Returns a getEmail . + * @return NSString containing Email + */ +- (NSString *)getEmail; + +/*! + * Returns MKTSecuritySignature valid or not . + * @return BOOL for MKTSecuritySignature is Valid . + */ +- (BOOL)isValid; + +@end diff --git a/framework/Marketo.framework/Versions/Current/Headers/Marketo.h b/framework/Marketo.framework/Versions/Current/Headers/Marketo.h new file mode 100644 index 0000000..311ec7f --- /dev/null +++ b/framework/Marketo.framework/Versions/Current/Headers/Marketo.h @@ -0,0 +1,156 @@ +// +// Marketo.h +// +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header Marketo.h + * @discussion The Marketo class is used to initialize the Marketo SDK. + */ + +#import +#import +#import +#import +#import +@interface Marketo : NSObject + +/*! + * Returns the App Secret used to initialize Marketo SDK. + */ +@property (nonatomic, readonly) NSString *appSecret; + +/*! + * Returns a singleton that is an instance of Marketo SDK. + * @return Singleton instance of class Marketo. + */ ++ (Marketo *)sharedInstance; + +/*! + * Initializes Marketo SDK. This method should be called before calling any other Marketo SDK method. + * @param appSecret An app secret used to initialize the app + * @param munchkinID Used to connect to marketo end-point + */ +- (void)initializeWithMunchkinID:(NSString *)munchkinID appSecret:(NSString *)appSecret launchOptions:(NSDictionary *)launchOptions; + +/*! + * The timeout interval, in seconds. If during a connection attempt the request remains idle for longer + * than the timeout interval, the request is considered to have timed out. + * The default timeout interval is 10 seconds. + */ +- (void)setTimeoutInterval:(NSInteger)seconds; + +/*! + * Reports an action to the Marketo server + * @param actionName The action to be reported + * @param metaData Optional - Use the setter methods to send metadata + * ex:- { + * "Action Type":"Shopping", + * "Action Details":"RedShirt", + * "Action Metric":10, + * "Action Length":30 + * } + */ +- (void)reportAction:(NSString *)actionName withMetaData:(MarketoActionMetaData *)metaData; + +/*! + * This function updates a single lead record from Marketo. + * If a lead without a matching email isn't found in the database, a new one is created + * @param lead Marketo Lead Object + */ +- (void)associateLead:(MarketoLead *)lead; + +/*! + * This function registers a Push Token. + * If a Push Token is already registered, just use registered token. + * @param deviceToken Token in form of NSData + */ +- (void)registerPushDeviceToken:(NSData *)deviceToken; + +/*! + * This function unregisters a Push Token. + * If a Push Token is already registered, call unregisterPushDeviceToken to unregister token. + */ +- (void)unregisterPushDeviceToken; + +/*! + * This tracks the push notification by sending an activity. + * @param userInfo Dictionary containing push payload + */ +- (void)trackPushNotification:(NSDictionary *)userInfo; + +/*! + * This function allows you to handle a push notificaiton appropriatly. + * @param userInfo Dictionary containing push payload + */ +- (void)handlePushNotification:(NSDictionary *)userInfo; + +/*! + * This function checks to see if a push token is already registered. + * @return true if push token has already been registered + */ +- (BOOL)isPushRegistered; + +/*! + * Deep link handler for Marketo Url and scheema + * @param application The singleton app object + * @param url The URL resource to open. This resource can be a network resource or a file. For information about the Apple-registered URL schemes, see + * @param sourceApplication The bundle ID of the app that is requesting your app to open the URL (url) + * @param annotation A property list object supplied by the source app to communicate information to the receiving app. + */ +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; + +/*! +* Override System's didReceiveLocalNotification method to Operate PushNotification +* @param application The singleton app object + * @param notification UILocalNotification object supplied by the source app. +*/ +- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification; + +/*! + * Override System's userNotificationCenter method to Operate PushNotification + * @param center The UNUserNotificationCenter object supplied by the source app. + * @param response UNNotificationResponse object supplied by the source app. + * @param completionHandler object supplied by the source app. + */ +- (void)userNotificationCenter:(UNUserNotificationCenter *)center +didReceiveNotificationResponse:(UNNotificationResponse *)response + withCompletionHandler:(void(^)())completionHandler; +/*! + * Set security Signature for Authentication + * @param token - The Security Token recived from client server + */ +- (void)setSecureSignature:(MKTSecuritySignature *)conf; + +/*! + * Remove security Signature from SDK . + * + */ +- (void)removeSecureSignature; + +/*! + * Returns a BOOL for the SDK enabled the Secure mode or not . + * + */ +- (BOOL)isSecureModeEnabled; + +/*! + * Returns a Device ID used by SDK. + * + */ +- (NSString *)getDeviceId; + +/*! + * Force report all data to Server. + * + */ +- (void)reportAll; + +/*! + * This object should be initialized via shared instance + */ +- (id)init __attribute__ ((unavailable ("cannot use init for this class, use +(Marketo*)sharedInstance instead"))); + +@end diff --git a/framework/Marketo.framework/Versions/Current/Headers/MarketoActionMetaData.h b/framework/Marketo.framework/Versions/Current/Headers/MarketoActionMetaData.h new file mode 100644 index 0000000..fef6346 --- /dev/null +++ b/framework/Marketo.framework/Versions/Current/Headers/MarketoActionMetaData.h @@ -0,0 +1,56 @@ +// +// MarketoActionMetadata.h +// +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header MarketoActionMetaData.h + * @discussion The MarketoActionMetaData class is used to encapsulate the action's metadata. + * @updated 2015-04-29 + */ + +#import + +@interface MarketoActionMetaData : NSObject + +- (id)init; + +/*! + * Set the action type + * @param type String phrase that describes the type of action + */ +- (void)setType:(NSString *)type; + +/*! + * Set the action details + * @param details String that contains more details about the action + */ +- (void)setDetails:(NSString *)details; + +/*! + * Set the action metric + * @param metric Number that represents the metric of the action + */ +- (void)setMetric:(NSNumber *)metric; + +/*! + * Set the action length + * @param length Number that represents the length of the action + */ +- (void)setLength:(NSNumber *)length; + +///*! +// * Set custom action metadata. +// * @param value String containing the value of the custom field +// */ +//-(void) setFieldName:(NSString *) name withValue:(NSString *) value; + +/*! + * Return action metadata. + * @return userData Dictionary containing action metadata + */ +- (NSDictionary *)actionMetadata; + +@end \ No newline at end of file diff --git a/framework/Marketo.framework/Versions/Current/Headers/MarketoLead.h b/framework/Marketo.framework/Versions/Current/Headers/MarketoLead.h new file mode 100644 index 0000000..0a4fa0a --- /dev/null +++ b/framework/Marketo.framework/Versions/Current/Headers/MarketoLead.h @@ -0,0 +1,128 @@ +// +// MarketoLead.h +// +// Marketo Mobile Engagement framework +// +// Copyright (c) 2007-2016, Marketo, Inc. All rights reserved. + +/*! + * @header MarketoLead.h + * @discussion The MarketoLead class is used associate a lead with attributes gathered by the application. + * @updated 2015-04-29 + */ + +#import + +@interface MarketoLead : NSObject + +- (id)init; + +/*! + * Update the lead's email. + * @param email The email to be associated with the device + */ +- (void)setEmail:(NSString *)email; + +/*! + * Update the lead's gender. + * @param gender String that represents lead's gender. ex. male, female + */ +- (void)setGender:(NSString *)gender; + +/*! + * Update the lead's first name. + * @param firstName String containing lead's first name + */ +- (void)setFirstName:(NSString *)firstName; + +/*! + * Update the lead's last name. + * @param lastName String containing lead's last name + */ +- (void)setLastName:(NSString *)lastName; + +/*! + * Update the lead's address. + * @param address String containing address of the lead + */ +- (void)setAddress:(NSString *)address; + +/*! + * Update the lead's city. + * @param city String containing name of the lead's city name + */ +- (void)setCity:(NSString *)city; + +/*! + * Update the lead's state. + * @param state String containing the lead's state name + */ +- (void)setState:(NSString *)state; + +/*! + * Update the lead's country. + * @param country String containing the lead's country name + */ +- (void)setCountry:(NSString *)country; + +/*! + * Update the lead's zipcode. + * @param postalCode String containing then lead's postal code + */ +- (void)setPostalCode:(NSString *)postalCode; + +/*! + * Update the lead's install source. ex. _facebookAds or bannerAds. + * @param leadSource String containing the lead's source + */ +- (void)setLeadSource:(NSString *)leadSource; + +/*! + * Update the lead's facebook id. + * @param facebookId String that contains the lead's facebook id + */ +- (void)setFacebookId:(NSString *)facebookId; + +/*! + * Update the lead's twitter id. + * @param twitterId String that contains the lead's twitter id + */ +- (void)setTwitterId:(NSString *)twitterId; + +/*! + * Update the lead's Linkedin id. + * @param LinkedInId String that contains the lead's LinkedIn id + */ +- (void)setLinkedInId:(NSString *)LinkedInId; + +/*! + * Update the lead's users birthday. + * @param birthday String that contains the lead's birthday with format MM/DD/YYYY + */ +- (void)setBirthDay:(NSString *)birthday; + +/*! + * Update the lead's facebook profile page url. + * @param url String that contains the url of the lead's Facebook profile page + */ +- (void)setFacebookProfileURL:(NSString *)url; + +/*! + * Update the lead's facebook profile picture url. + * @param url String that contains the url of the lead's Facebook profile picture + */ +- (void)setFacebookProfilePicURL:(NSString *)url; + +/*! + * Update the lead's custom attributes. + * @param value String that represents the value of the custom field + */ +- (void)setFieldName:(NSString *)name withValue:(NSString *)value; + +/*! + * Return lead attributes. + * @return userData Dictionary containing leadData + */ +- (NSDictionary *)userData; + +@end diff --git a/framework/Marketo.framework/Versions/Current/Marketo b/framework/Marketo.framework/Versions/Current/Marketo new file mode 100644 index 0000000..0c0852f Binary files /dev/null and b/framework/Marketo.framework/Versions/Current/Marketo differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..edb3b1e --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "MarketoPlugin", + "version": "0.7.8", + "description": "Marketo plugin", + "cordova": { + "id": "com.marketo.plugin", + "platforms": [ + "android", + "ios" + ] + }, + "repository": { + "type": "git", + "url": "git+https://github.com/olakra/PhoneGapPlugin.git" + }, + "keywords": [ + "phonegap", + "Marketo", + "ecosystem:cordova", + "cordova-android", + "cordova-ios" + ], + "author": "Rudy Gomez", + "license": "Apache", + "bugs": { + "url": "https://github.com/Marketo/PhoneGapPlugin/issues" + }, + "homepage": "https://github.com/Marketo/PhoneGapPlugin#readme" +} diff --git a/plugin.xml b/plugin.xml index 4976d0d..1987ab0 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,47 +2,111 @@ + version="0.7.8"> MarketoPlugin Marketo plugin Apache phonegap, Marketo + - + + + + + 1.We are using application secret key ='$APPLICATION_SECRET_KEY' to configure your Marketo PhoneGap plugin for Android. + 2.Adding Marketo Activity, Marketo Boradcast Receiver. + 3.Adding required permission for push notification. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - Register your application at Marketo.com for further documentation. + Successfully added Marketo PhoneGap Plugin. + - - - + + + + + CFBundleURLSchemes + + mkto-$APPLICATION_SECRET_KEY + + + + + + + + + + + + + + + + + + + + - Register your application at Marketo.com for further documentation. + 1. We are using application secret key ='$APPLICATION_SECRET_KEY' to configure your Marketo PhoneGap plugin for iOS. + 2. Adding new URL schedule to handle test devices registration. + 3. Successfully added Marketo PhoneGap Plugin for iOS. - + + diff --git a/src/android/Marketo.gradle b/src/android/Marketo.gradle new file mode 100644 index 0000000..b99af37 --- /dev/null +++ b/src/android/Marketo.gradle @@ -0,0 +1,21 @@ +repositories{ + jcenter() + flatDir{ + dirs 'aar' + } +} + +dependencies { + compile(name:'MarketoRelease', ext:'aar') +} + +android { + packagingOptions { + exclude 'META-INF/NOTICE' + exclude 'META-INF/LICENSE' + } +} +cdvPluginPostBuildExtras.add({ + apply plugin: 'com.google.gms.google-services' + apply plugin: 'io.fabric' +}) diff --git a/src/android/MarketoPlugin.java b/src/android/MarketoPlugin.java old mode 100644 new mode 100755 index 2150043..50d5814 --- a/src/android/MarketoPlugin.java +++ b/src/android/MarketoPlugin.java @@ -1,14 +1,23 @@ package com.marketo.plugin; +import android.content.SharedPreferences; +import android.content.res.AssetManager; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.util.Log; + +import java.io.FileNotFoundException; +import java.io.InputStream; import java.util.Iterator; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; + import android.app.Activity; import com.marketo.Marketo; import com.marketo.MarketoActionMetaData; +import com.marketo.MarketoConfig; import com.marketo.MarketoLead; import com.marketo.errors.MktoException; @@ -17,221 +26,337 @@ import org.json.JSONException; public class MarketoPlugin extends CordovaPlugin { - public static final String KEY_ACTION_TYPE = "Action Type"; -public static final String KEY_ACTION_DETAILS = "Action Details"; -public static final String KEY_ACTION_METRIC = "Action Metric"; -public static final String KEY_ACTION_LENGTH = "Action Length"; - -public static final String KEY_FIRST_NAME = "firstName"; -public static final String KEY_LAST_NAME = "lastName"; -public static final String KEY_ADDRESS = "address"; -public static final String KEY_CITY = "city"; -public static final String KEY_STATE = "state"; -public static final String KEY_COUNTRY = "country"; -public static final String KEY_POSTAL_CODE = "postalCode"; -public static final String KEY_GENDER = "gender"; -public static final String KEY_EMAIL = "email"; - -public static final String KEY_TWITTER = "twitterId"; -public static final String KEY_FACEBOOK = "facebookId"; -public static final String KEY_LINKEDIN = "linkedinId"; -public static final String KEY_LEAD_SOURCE = "leadSource"; -public static final String KEY_BIRTHDAY = "dateOfBirth"; -public static final String KEY_FACEBOOK_PROFILE_URL = "facebookProfileURL"; -public static final String KEY_FACEBOOK_PROFILE_PIC = "facebookPhotoURL"; -private CallbackContext callbackContext; -private Activity activityContext; - -@Override -public boolean execute(String action, JSONArray args, CallbackContext _callbackContext) throws JSONException { - try { - callbackContext = _callbackContext; - activityContext = this.cordova.getActivity(); - final Marketo marketo = Marketo.getInstance(activityContext); - Log.d("MarketoSDK", "Action "+action); - if ("initialize".equals(action)) { - final String MUCHKIN_ID = args.optString(0); - final String SECRET_KEY = args.optString(1); - this.cordova.getThreadPool().execute(new Runnable() { - - @Override - public void run() { - marketo.initializeSDK(MUCHKIN_ID, SECRET_KEY); - callbackContext.success(); - } - }); - return true; - } else if ("initializeMarketoPush".equals(action)) { - final String PROJECT_ID = args.optString(0); - this.cordova.getThreadPool().execute(new Runnable() { - - @Override - public void run() { - marketo.initializeMarketoPush(PROJECT_ID); - callbackContext.success(); - } - }); - return true; - } else if ("associateLead".equals(action)) { - final JSONObject jsonObject = args.getJSONObject(0); - this.cordova.getThreadPool().execute(new Runnable() { - - @Override - public void run() { - marketo.associateLead(getLeaad(jsonObject)); - callbackContext.success(); - } - }); - return true; - } else if ("onStop".equals(action)) { - this.cordova.getThreadPool().execute(new Runnable() { - - @Override - public void run() { - Marketo.onStop(activityContext); - callbackContext.success(); - } - }); - return true; - } else if ("onStart".equals(action)) { - this.cordova.getThreadPool().execute(new Runnable() { - - @Override - public void run() { - Marketo.onStart(activityContext); - callbackContext.success(); + public static final String KEY_ACTION_TYPE = "Action Type"; + public static final String KEY_ACTION_DETAILS = "Action Details"; + public static final String KEY_ACTION_METRIC = "Action Metric"; + public static final String KEY_ACTION_LENGTH = "Action Length"; + + public static final String KEY_FIRST_NAME = "firstName"; + public static final String KEY_LAST_NAME = "lastName"; + public static final String KEY_ADDRESS = "address"; + public static final String KEY_CITY = "city"; + public static final String KEY_STATE = "state"; + public static final String KEY_COUNTRY = "country"; + public static final String KEY_POSTAL_CODE = "postalCode"; + public static final String KEY_GENDER = "gender"; + public static final String KEY_EMAIL = "email"; + + public static final String KEY_TWITTER = "twitterId"; + public static final String KEY_FACEBOOK = "facebookId"; + public static final String KEY_LINKEDIN = "linkedinId"; + public static final String KEY_LEAD_SOURCE = "leadSource"; + public static final String KEY_BIRTHDAY = "dateOfBirth"; + public static final String KEY_FACEBOOK_PROFILE_URL = "facebookProfileURL"; + public static final String KEY_FACEBOOK_PROFILE_PIC = "facebookPhotoURL"; + + public static final String KEY_FOR_NOTIFICATION_ICON = "notification.icon_path"; + private CallbackContext callbackContext; + private Activity activityContext; + + @Override + public boolean execute(String action, JSONArray args, CallbackContext _callbackContext) throws JSONException { + try { + callbackContext = _callbackContext; + activityContext = this.cordova.getActivity(); + final Marketo marketo = Marketo.getInstance(activityContext); + Log.d("MarketoSDK", "Action " + action); + if ("initialize".equals(action)) { + final String MUCHKIN_ID = args.optString(0); + final String SECRET_KEY = args.optString(1); + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + marketo.setPhonegapCurrentActivity(activityContext); + marketo.initializeSDK(MUCHKIN_ID, SECRET_KEY); + callbackContext.success(); + } + }); + return true; + } else if ("initializeMarketoPush".equals(action)) { + final String PROJECT_ID = args.optString(0); + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + marketo.initializeMarketoPush(PROJECT_ID); + callbackContext.success(); + } + }); + return true; + } else if ("associateLead".equals(action)) { + final JSONObject jsonObject = new JSONObject(args.optString(0)); + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + marketo.associateLead(getLeaad(jsonObject)); + callbackContext.success(); + } + }); + return true; + } else if ("onStop".equals(action)) { + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + // Marketo.onStop(activityContext); + callbackContext.success(); + } + }); + return true; + } else if ("onStart".equals(action)) { + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + // Marketo.onStart(activityContext); + callbackContext.success(); + } + }); + return true; + } else if ("reportaction".equals(action)) { + final String REPORT_ACTION = args.optString(0); + final JSONObject json = new JSONObject(args.optString(1)); + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + Marketo.reportAction(REPORT_ACTION, getMetadata(json)); + callbackContext.success(); + } + }); + return true; + } else if ("removeSecureSignature".equals(action)) { + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + marketo.removeSecureSignature(); + callbackContext.success(); + } + }); + return true; + } else if ("isSecureModeEnabled".equals(action)) { + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + callbackContext.success(Marketo.isSecureModeEnabled() ? 1 : 0); + } + }); + return true; + } else if ("setSecureSignature".equals(action)) { + final String accessKey = args.optString(0); + final String signature = args.optString(1); + final String email = args.optString(2); + final long timestamp = args.optLong(3); + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + MarketoConfig.SecureMode secureMode = new MarketoConfig.SecureMode(); + secureMode.setAccessKey(accessKey); + secureMode.setEmail(email); + secureMode.setSignature(signature); + secureMode.setTimestamp(timestamp); + marketo.setSecureSignature(secureMode); + callbackContext.success(); + } + }); + return true; + } else if ("getDeviceId".equals(action)) { + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + callbackContext.success(marketo.getDeviceId()); + } + }); + return true; + } else if ("setNotificationConfig".equals(action)) { + final Bitmap bitmap = getBitMap(args.optString(0)); + final int id = getResourceID(args.optString(1)); + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + MarketoConfig.Notification config = new MarketoConfig.Notification(); + config.setNotificationLargeIcon(bitmap); + config.setNotificationSmallIcon(id); + marketo.setNotificationConfig(config); + callbackContext.success(); + } + }); + return true; + } else if ("getNotificationConfig".equals(action)) { + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + MarketoConfig.Notification config = marketo.getNotificationConfig(); + JSONArray object = new JSONArray(); + object.put(BitMapPath()); + object.put(getResourseName(config.getNotificationSmallIcon())); + callbackContext.success(object); + } + }); + return true; + } else if ("uninitializeMarketoPush".equals(action)) { + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + marketo.uninitializeMarketoPush(); + callbackContext.success(); + } + }); + return true; + } else if ("settimeout".equals(action)) { + final int TIME_OUT = args.optInt(0); + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + Marketo.setNetworkTimeout(TIME_OUT); + callbackContext.success(); + } + }); + return true; + } else if ("reportAll".equals(action)) { + this.cordova.getThreadPool().execute(new Runnable() { + + @Override + public void run() { + Marketo.reportAll(); + callbackContext.success(); + } + }); + return true; + } + return false; + } catch (Exception e) { + e.printStackTrace(); + callbackContext.error(e.getMessage()); + return false; } - }); - return true; - } else if("reportaction".equals(action)){ - final String REPORT_ACTION = args.optString(0); - final JSONObject json = args.optJSONObject(1); - this.cordova.getThreadPool().execute(new Runnable() { - - @Override - public void run() { - Marketo.reportAction(REPORT_ACTION, getMetadata(json)); - callbackContext.success(); + } + + public int getResourceID(String resourceName) { + return activityContext.getResources().getIdentifier(resourceName, "drawable", activityContext.getPackageName()); + } + + public String getResourseName(int resoirceID) { + return activityContext.getResources().getResourceEntryName(resoirceID); + } + + public Bitmap getBitMap(String filePath) { + Bitmap bitmap = null; + try { + SharedPreferences settings = activityContext.getSharedPreferences("com.mkt.phonegap", 0); + SharedPreferences.Editor editor = settings.edit(); + editor.putString(KEY_FOR_NOTIFICATION_ICON, filePath); + editor.commit(); + AssetManager assetManager = activityContext.getAssets(); + InputStream istr = null; + istr = assetManager.open(filePath); + bitmap = BitmapFactory.decodeStream(istr); + } catch (FileNotFoundException e) { + e.printStackTrace(); + callbackContext.error("Failed to locate asset file"); + } catch (Exception e) { + e.printStackTrace(); + callbackContext.error(e.getMessage()); } - }); - return true; - } else if("settimeout".equals(action)){ - final int TIME_OUT = args.optInt(0); - this.cordova.getThreadPool().execute(new Runnable() { - - @Override - public void run() { - Marketo.setNetworkTimeout(TIME_OUT); - callbackContext.success(); + return bitmap; + } + + public String BitMapPath() { + String result = null; + if (activityContext != null) { + SharedPreferences settings = activityContext.getSharedPreferences("com.mkt.phonegap", 0); + try { + result = settings.getString(KEY_FOR_NOTIFICATION_ICON, ""); + } catch (ClassCastException ex) { + } } - }); - return true; + return result; } - return false; - } catch(Exception e) { - e.printStackTrace(); - callbackContext.error(e.getMessage()); - return false; - } -} -private MarketoActionMetaData getMetadata(JSONObject json) { - MarketoActionMetaData actionMetaData = new MarketoActionMetaData(); - try { - Iterator items = json.keys(); - for (Iterator iterator = items; iterator.hasNext(); ) { - String key = iterator.next(); - String value = json.optString(key); - switch (key) { - case KEY_ACTION_TYPE: - actionMetaData.setActionType(value); - break; - case KEY_ACTION_DETAILS: - actionMetaData.setActionDetails(value); - break; - case KEY_ACTION_LENGTH: - actionMetaData.setActionLength(value); - break; - case KEY_ACTION_METRIC: - actionMetaData.setActionMetric(value); - break; - } - } - }catch(Exception e){ - e.printStackTrace(); - } - return actionMetaData; -} + private MarketoActionMetaData getMetadata(JSONObject json) { + MarketoActionMetaData actionMetaData = new MarketoActionMetaData(); + try { + Iterator items = json.keys(); + for (; items.hasNext(); ) { + String key = items.next(); + String value = json.optString(key); + if (key.equals(KEY_ACTION_TYPE)) { + actionMetaData.setActionType(value); + } else if (key.equals(KEY_ACTION_DETAILS)) { + actionMetaData.setActionDetails(value); + } else if (key.equals(KEY_ACTION_LENGTH)) { + actionMetaData.setActionLength(value); + } else if (key.equals(KEY_ACTION_METRIC)) { + actionMetaData.setActionMetric(value); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return actionMetaData; + } -private MarketoLead getLeaad(JSONObject object) { - MarketoLead lead = new MarketoLead(); - try { - @SuppressWarnings("unchecked") - Iterator items = object.keys(); - for (Iterator iterator = items; iterator.hasNext(); ) { - String key = iterator.next(); - String value = object.optString(key); - switch (key) { - case KEY_FIRST_NAME: - lead.setFirstName(value); - break; - case KEY_LAST_NAME: - lead.setLastName(value); - break; - case KEY_ADDRESS: - lead.setAddress(value); - break; - case KEY_CITY: - lead.setCity(value); - break; - case KEY_STATE: - lead.setState(value); - break; - case KEY_COUNTRY: - lead.setCountry(value); - break; - case KEY_POSTAL_CODE: - lead.setPostalCode(value); - break; - case KEY_GENDER: - lead.setGender(value); - break; - case KEY_EMAIL: - try { - lead.setEmail(value); - } catch (MktoException e) { + private MarketoLead getLeaad(JSONObject object) { + MarketoLead lead = new MarketoLead(); + try { + @SuppressWarnings("unchecked") + Iterator items = object.keys(); + for (; items.hasNext(); ) { + String key = items.next(); + String value = object.optString(key); + if (key.equals(KEY_FIRST_NAME)) { + lead.setFirstName(value); + } else if (key.equals(KEY_LAST_NAME)) { + lead.setLastName(value); + } else if (key.equals(KEY_ADDRESS)) { + lead.setAddress(value); + } else if (key.equals(KEY_CITY)) { + lead.setCity(value); + } else if (key.equals(KEY_STATE)) { + lead.setState(value); + } else if (key.equals(KEY_COUNTRY)) { + lead.setCountry(value); + } else if (key.equals(KEY_POSTAL_CODE)) { + lead.setPostalCode(value); + } else if (key.equals(KEY_GENDER)) { + lead.setGender(value); + } else if (key.equals(KEY_EMAIL)) { + try { + lead.setEmail(value); + } catch (MktoException e) { + e.printStackTrace(); + } + } else if (key.equals(KEY_TWITTER)) { + lead.setTwitterId(value); + } else if (key.equals(KEY_FACEBOOK)) { + lead.setFacebookId(value); + } else if (key.equals(KEY_LINKEDIN)) { + lead.setLinkedinId(value); + } else if (key.equals(KEY_LEAD_SOURCE)) { + lead.setLeadSource(value); + } else if (key.equals(KEY_BIRTHDAY)) { + lead.setBirthDay(value); + } else if (key.equals(KEY_FACEBOOK_PROFILE_PIC)) { + lead.setFacebookProfilePicURL(value); + } else if (key.equals(KEY_FACEBOOK_PROFILE_URL)) { + lead.setFacebookProfileURL(value); + } else { + lead.setCustomField(key, value); + } + } + } catch (Exception e) { e.printStackTrace(); - } - break; - case KEY_TWITTER: - lead.setTwitterId(value); - break; - case KEY_FACEBOOK: - lead.setFacebookId(value); - break; - case KEY_LINKEDIN: - lead.setLinkedinId(value); - break; - case KEY_LEAD_SOURCE: - lead.setLeadSource(value); - break; - case KEY_BIRTHDAY: - lead.setBirthDay(value); - break; - case KEY_FACEBOOK_PROFILE_PIC: - lead.setFacebookProfilePicURL(value); - break; - case KEY_FACEBOOK_PROFILE_URL: - lead.setFacebookProfileURL(value); - break; - default: - lead.setCustomField(key, value); - break; - } + } + return lead; } - }catch (Exception e){ - e.printStackTrace(); - } - return lead; -} } diff --git a/src/ios/AppDelegate+Marketo.h b/src/ios/AppDelegate+Marketo.h new file mode 100644 index 0000000..71e5120 --- /dev/null +++ b/src/ios/AppDelegate+Marketo.h @@ -0,0 +1,13 @@ +// +// AppDelegate+Marketo.h +// PhoneGapSample +// +// Created by Rohit Mahto on 16/06/16. +// +// + +#import "AppDelegate.h" +#import +@interface AppDelegate (Marketo) + +@end diff --git a/src/ios/AppDelegate+Marketo.m b/src/ios/AppDelegate+Marketo.m new file mode 100644 index 0000000..871a1e7 --- /dev/null +++ b/src/ios/AppDelegate+Marketo.m @@ -0,0 +1,88 @@ +// +// AppDelegate+Marketo.m +// PhoneGapSample +// +// Created by Rohit Mahto on 16/06/16. +// +// + +#import "AppDelegate+Marketo.h" +#import +@implementation AppDelegate (Marketo) + +#define XCODE_VERSION_GREATER_THAN_OR_EQUAL_TO_8 __has_include() + +// To handle deeplink received from Marketo. +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation +{ + return [[Marketo sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; +} + +#ifdef __IPHONE_8_0 +- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings +{ + // register to receive notifications + [application registerForRemoteNotifications]; +} + +#endif + +// Will update the Push Token received from apns. +- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken +{ +#if XCODE_VERSION_GREATER_THAN_OR_EQUAL_TO_8 + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + center.delegate = self; + [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) + completionHandler:^(BOOL granted, NSError * _Nullable error) { + if (!error) { + NSLog(@"Local notification request authorization succeeded!"); + } + }]; +#endif + [[Marketo sharedInstance] registerPushDeviceToken:deviceToken]; +} + +// To handle Push notifications received from marketo. +- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo +{ + [[Marketo sharedInstance] handlePushNotification:userInfo]; +} + +// To handle Local notifications received from marketo. +- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification +{ + [[Marketo sharedInstance] application:application didReceiveLocalNotification:notification]; +} + +-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{ + NSLog(@"Unable to get push token ******-> %@", error); +} + +#if XCODE_VERSION_GREATER_THAN_OR_EQUAL_TO_8 + +// The method will be called on the delegate only if the application is in the foreground. If the method is not implemented or the handler is not called in a timely manner then the notification will not be presented. The application can choose to have the notification presented as a sound, badge, alert and/or in the notification list. This decision should be based on whether the information in the notification is otherwise visible to the user. +- (void)userNotificationCenter:(UNUserNotificationCenter *)center + willPresentNotification:(UNNotification *)notification + withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { + NSLog(@"Notification is triggered"); + + // You can either present alert, sound or increase badge while the app is in foreground too with iOS 10 + // Must be called when finished, when you do not want foreground show, pass UNNotificationPresentationOptionNone to the completionHandler() + completionHandler(UNNotificationPresentationOptionAlert); + // completionHandler(UNNotificationPresentationOptionBadge); + // completionHandler(UNNotificationPresentationOptionSound); +} + +// The method will be called on the delegate when the user responded to the notification by opening the application, dismissing the notification or choosing a UNNotificationAction. The delegate must be set before the application returns from applicationDidFinishLaunching:. +- (void)userNotificationCenter:(UNUserNotificationCenter *)center +didReceiveNotificationResponse:(UNNotificationResponse *)response + withCompletionHandler:(void(^)())completionHandler { + [[Marketo sharedInstance] userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler]; +// completionHandler(); +} + +#endif + + +@end diff --git a/src/ios/MarketoPlugin.h b/src/ios/MarketoPlugin.h index f494b16..fd49bf0 100755 --- a/src/ios/MarketoPlugin.h +++ b/src/ios/MarketoPlugin.h @@ -4,11 +4,17 @@ @interface MarketoPlugin : CDVPlugin -- (void)initialize:(CDVInvokedUrlCommand*)command; -- (void)resume:(CDVInvokedUrlCommand*)command; -- (void)pause:(CDVInvokedUrlCommand*)command; -- (void) settimeoutinterval:(CDVInvokedUrlCommand*)command; +- (void) initialize:(CDVInvokedUrlCommand*)command; +- (void) initializeMarketoPush:(CDVInvokedUrlCommand*)command; +- (void) onStart:(CDVInvokedUrlCommand*)command; +- (void) onStop:(CDVInvokedUrlCommand*)command; +- (void) settimeout:(CDVInvokedUrlCommand*)command; - (void) reportaction:(CDVInvokedUrlCommand*)command; -- (void) associatelead:(CDVInvokedUrlCommand*)command; - -@end \ No newline at end of file +- (void) associateLead:(CDVInvokedUrlCommand*)command; +- (void) setSecureSignature:(CDVInvokedUrlCommand*)command; +- (void) removeSecureSignature:(CDVInvokedUrlCommand*)command; +- (void) getDeviceId:(CDVInvokedUrlCommand*)command; +- (void) isSecureModeEnabled:(CDVInvokedUrlCommand*)command; +- (void) reportAll:(CDVInvokedUrlCommand*)command; +- (void) uninitializeMarketoPush:(CDVInvokedUrlCommand*)command; +@end diff --git a/src/ios/MarketoPlugin.m b/src/ios/MarketoPlugin.m index d31df19..8cf7fb0 100755 --- a/src/ios/MarketoPlugin.m +++ b/src/ios/MarketoPlugin.m @@ -20,9 +20,6 @@ Licensed to the Apache Software Foundation (ASF) under one #import "MarketoPlugin.h" - - - @implementation MarketoPlugin - (void)pluginInitialize { @@ -30,7 +27,6 @@ - (void)pluginInitialize { NSLog(@"MarketoSDK plugin"); } - - (void)onAppTerminate { NSLog(@"MarketoSDK, onAppTerminate"); @@ -49,6 +45,7 @@ - (void)dispose { NSLog(@"MarketoSDK, dispose"); } +//if action is initialize then it will initialize the marketo SDK - (void)initialize:(CDVInvokedUrlCommand*)command { dispatch_async(dispatch_get_global_queue(0, 0), ^{ @@ -56,6 +53,10 @@ - (void)initialize:(CDVInvokedUrlCommand*)command NSString* munchkinID = [command.arguments objectAtIndex:0]; NSString* secretKey = [command.arguments objectAtIndex:1]; + if([self isObjectnull: munchkinID] || [self isObjectnull: secretKey]){ + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"munchkinID or secretKey was null"]; + return; + } if (secretKey != nil && munchkinID !=nil) { [[Marketo sharedInstance] initializeWithMunchkinID:munchkinID appSecret:secretKey launchOptions:nil]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; @@ -66,30 +67,62 @@ - (void)initialize:(CDVInvokedUrlCommand*)command }); } -- (void)resume:(CDVInvokedUrlCommand*)command +//if action is initializeMarketoPush then it will initialize the Push notification service for the app +- (void) initializeMarketoPush:(CDVInvokedUrlCommand*)command{ + dispatch_async(dispatch_get_global_queue(0, 0), ^{ + UIApplication *application = [UIApplication sharedApplication]; + if ([application respondsToSelector:@selector (registerUserNotificationSettings:)]) + { +#ifdef __IPHONE_8_0 + UIUserNotificationSettings *settings = + [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert) categories:nil]; + [application registerUserNotificationSettings:settings]; +#endif + } + else + { + UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound; + [application registerForRemoteNotificationTypes:myTypes]; + } + [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK ] callbackId:command.callbackId]; + }); +} + +//if action is resume then it will send the resume action to MarketoSDK +- (void)onStart:(CDVInvokedUrlCommand*)command { + // For iOS we handle it automatically. + // Added this call to keep it consistent with android. CDVPluginResult* pluginResult = nil; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } -- (void)pause:(CDVInvokedUrlCommand*)command +//if action is pause then it will send the pause action to MarketoSDK +- (void)onStop:(CDVInvokedUrlCommand*)command { + // For iOS we handle it automatically. + // Added this call to keep it consistent with android. CDVPluginResult* pluginResult = nil; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } -- (void) settimeoutinterval:(CDVInvokedUrlCommand*)command{ +//if action is settimeout then it will det the default time out to the value from json +- (void) settimeout:(CDVInvokedUrlCommand*)command{ dispatch_async(dispatch_get_global_queue(0, 0), ^{ CDVPluginResult* pluginResult = nil; + if([self isObjectnull: [command.arguments objectAtIndex:0]]){ + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"invalid timeout value ."]; + return; + } NSNumber* timeOut = [NSNumber numberWithFloat:[[command.arguments objectAtIndex:0] floatValue]]; if(timeOut!=0){ [[Marketo sharedInstance] setTimeoutInterval:[timeOut intValue]]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; }else{ - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"invalid timeout value ."]; } [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; @@ -97,51 +130,130 @@ - (void) settimeoutinterval:(CDVInvokedUrlCommand*)command{ } +/** +* reportaction is a method which will create a MarketoActionMetaData object +* out of the JSONObject passed as a parameter +* +* @param JSONObject is a json data of Custom Action +*/ + - (void) reportaction:(CDVInvokedUrlCommand*)command{ dispatch_async(dispatch_get_global_queue(0, 0), ^{ CDVPluginResult* pluginResult = nil; NSString* reportAction = [command.arguments objectAtIndex:0] ; NSString* reportData = [command.arguments objectAtIndex:1] ; NSError * error; - if((reportAction!=nil && reportAction.length!=0) || (reportData!=nil && reportData.length!=0)){ + if(![self isObjectnull:reportAction] && ![self isObjectnull:reportData]){ NSDictionary *leadDictinary = [NSJSONSerialization JSONObjectWithData:[reportData dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&error]; - if(error!=nil || leadDictinary!=nil){ + if(error==nil && leadDictinary!=nil){ MarketoActionMetaData *data =[[MarketoActionMetaData alloc]init]; - [data setValue:[leadDictinary objectForKey:@"data"] forKeyPath:@"actionMetadata"]; - [[Marketo sharedInstance] reportAction:[leadDictinary objectForKey:@"event"] withMetaData:data]; + [data setType:[leadDictinary objectForKey:@"Action Type"]]; + [data setDetails:[leadDictinary objectForKey:@"Action Details"]]; + [data setMetric:[leadDictinary objectForKey:@"Action Metric"]]; + [data setLength:[leadDictinary objectForKey:@"Action Length"]]; + [[Marketo sharedInstance] reportAction:reportAction withMetaData:data]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; }else{ - NSLog(@"Can not report data , issue with json data"); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Can not report data, issue with report data"]; } [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; }else{ - NSLog(@"Can not report data , issue with report data"); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Can not report data, issue with report data"]; } }); } -- (void) associatelead:(CDVInvokedUrlCommand*)command{ +/** +* associatelead is a method which will create a MarketoLead object +* out of the JSONObject passed as a parameter +* +* @param CDVInvokedUrlCommand contains json data related to lead +*/ +- (void) associateLead:(CDVInvokedUrlCommand*)command{ dispatch_async(dispatch_get_global_queue(0, 0), ^{ CDVPluginResult* pluginResult = nil; NSString* leadData = [command.arguments objectAtIndex:0] ; NSError * error; + if([self isObjectnull:leadData]){ + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Failed to associate lead"]; + return ; + } NSDictionary *leadDictinary = [NSJSONSerialization JSONObjectWithData:[leadData dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&error]; - if(error!=nil || leadDictinary!=nil){ + if(error==nil && leadDictinary!=nil){ MarketoLead * lead=[[MarketoLead alloc] init]; [lead setValue:leadDictinary forKeyPath:@"userAttributes"]; [[Marketo sharedInstance] associateLead:lead]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; }else{ - NSLog(@"Can not parce lead , issue with json data"); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Failed to associate lead"]; + } + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }); +} + +- (void) setSecureSignature:(CDVInvokedUrlCommand*)command{ + dispatch_async(dispatch_get_global_queue(0, 0), ^{ + CDVPluginResult* pluginResult = nil; + NSString* accessKey = [command.arguments objectAtIndex:0] ; + NSString* signature = [command.arguments objectAtIndex:1] ; + NSString* email = [command.arguments objectAtIndex:2] ; + NSString* timestamp = [command.arguments objectAtIndex:3] ; + if([self isObjectnull:accessKey] || [self isObjectnull:signature] || [self isObjectnull:email] || [self isObjectnull:timestamp]){ + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid MKTSecuritySignature."]; + } + MKTSecuritySignature * mktSecuritySignature = [[MKTSecuritySignature alloc] initWithAccessKey:accessKey signature:signature timestamp:timestamp email:email]; + if(mktSecuritySignature!=nil ){ + [[Marketo sharedInstance] setSecureSignature:mktSecuritySignature]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + }else{ + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid MKTSecuritySignature."]; } [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; }); } +- (void) removeSecureSignature:(CDVInvokedUrlCommand*)command{ + dispatch_async(dispatch_get_global_queue(0, 0), ^{ + [[Marketo sharedInstance] removeSecureSignature]; + [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK ] callbackId:command.callbackId]; + }); +} +- (void) getDeviceId:(CDVInvokedUrlCommand*)command{ + dispatch_async(dispatch_get_global_queue(0, 0), ^{ + NSString * deviceId= [[Marketo sharedInstance] getDeviceId]; + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:deviceId];; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }); +} +- (void) uninitializeMarketoPush:(CDVInvokedUrlCommand*)command{ + dispatch_async(dispatch_get_global_queue(0, 0), ^{ + [[Marketo sharedInstance] unregisterPushDeviceToken]; + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }); +} +- (void) isSecureModeEnabled:(CDVInvokedUrlCommand*)command{ + dispatch_async(dispatch_get_global_queue(0, 0), ^{ + BOOL isSecureModeEnabled = [[Marketo sharedInstance] isSecureModeEnabled]; + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:isSecureModeEnabled?1:0];; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }); +} + +- (void) reportAll:(CDVInvokedUrlCommand*)command{ + dispatch_async(dispatch_get_global_queue(0, 0), ^{ + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [[Marketo sharedInstance] reportAll]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }); +} +-(BOOL) isObjectnull:(id )value{ + if([value isEqual:[NSNull null] ] || !value){ + return YES; + } + return NO; +} @end diff --git a/www/marketo.js b/www/marketo.js index 31e644d..e563695 100644 --- a/www/marketo.js +++ b/www/marketo.js @@ -19,6 +19,23 @@ */ var marketo = { + "KEY_FIRST_NAME" : "firstName", + "KEY_LAST_NAME" : "lastName", + "KEY_ADDRESS" : "address", + "KEY_CITY" : "city", + "KEY_STATE" : "state", + "KEY_COUNTRY" : "country", + "KEY_POSTAL_CODE" : "postalCode", + "KEY_GENDER" : "gender", + "KEY_EMAIL" : "email", + "KEY_TWITTER" : "twitterId", + "KEY_FACEBOOK" : "facebookId", + "KEY_LINKEDIN" : "linkedinId", + "KEY_LEAD_SOURCE" : "leadSource", + "KEY_BIRTHDAY" : "dateOfBirth", + "KEY_FACEBOOK_PROFILE_URL" : "facebookProfileURL", + "KEY_FACEBOOK_PROFILE_PIC" : "facebookPhotoURL", + /** * Call this method when user wants to initialize marketo application * Action name should be @@ -99,6 +116,80 @@ var marketo = { "reportaction", [reportAction, action_metadata]); }, + /** + * Call this method when user wants to remove secure signature + * + * @param success the message if successful + * @param fail the message if the action fails + */ + removeSecureSignature: function (success, fail) { + return cordova.exec( success, fail, + "MarketoPlugin", + "removeSecureSignature", []); + }, + + /** + * Call this method when user wants to set the request's timeout + * + * @param success the message if successful + * @param fail the message if the action fails + * @param secureMode represents the secure signature information in Json format + */ + setSecureSignature: function (success, fail, accessKey, signature, email, timestamp) { + return cordova.exec(success, fail, + "MarketoPlugin", + "setSecureSignature", [accessKey, signature, email, timestamp]); + }, + + /** + * Call this method when user wants to check the status of secure mode + * + * @param success contains the boolean flag to check whether secure mode is on or off. + * @param fail the message if the action fails + */ + isSecureModeEnabled: function (success, fail) { + return cordova.exec(success, fail, + "MarketoPlugin", + "isSecureModeEnabled",[]); + }, + + /** + * Helper method to get DeviceId. + * @param success should be the function which takes device id as a parameter ex. function(deviceid){ ... } + * @param fail the message if the action fails + * @return This method will return device ID if the MarketoSDK is initialized, otherwise will return null + */ + getDeviceId: function (success, fail) { + return cordova.exec(success, fail, + "MarketoPlugin", + "getDeviceId", []); + }, + + /** + * Helper method to set notification configeration. + * @param success the message if successful + * @param fail the message if the action fails + * @param image path for large notification icon. Available only Android Honeycomb and Above + * @param resourceName should be the name of the resource for the small notification icon + */ + setNotificationConfig: function (success, fail, imagePath, resourceName) { + return cordova.exec(success, fail, + "MarketoPlugin", + "setNotificationConfig", [imagePath, resourceName]); + }, + + /** + * Helper method to get DeviceId. + * @param success should be the function which takes JSONArray as a parameter ex. function(config){ ... } + * @param fail the message if the action fails + * @return This method will return the notification configerations + */ + getNotificationConfig: function (success, fail) { + return cordova.exec(success, fail, + "MarketoPlugin", + "getNotificationConfig", []); + }, + /** * Call this method when user wants to set the request's timeout * @@ -110,6 +201,24 @@ var marketo = { return cordova.exec(success, fail, "MarketoPlugin", "settimeout", [timeout]); + }, + + /** + * Call this method when user wants to force report all custom action and events along with there respective metadata + */ + reportAll: function(success, fail){ + return cordova.exec(success,fail, + "MarketoPlugin", + "reportAll", []); + }, + + /** + * Call this method when user wants to unregister his device for push notification + */ + uninitializeMarketoPush: function(success, fail){ + return cordova.exec(success,fail, + "MarketoPlugin", + "uninitializeMarketoPush", []); } } module.exports = marketo;